#include "stm32f10x.h"
#include "delay.h"
#include "led.h"
#include "misc.h"
void RCC_Configuration(void)
{
SystemInit();
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD,ENABLE);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_8|GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽输出led
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //口线翻转速度为50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_8);
GPIO_SetBits(GPIOD,GPIO_Pin_2);
}
void WWDG_NVIC_Init()
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = WWDG_IRQn; //WWDG中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0; //抢占2,子优先级3,组2
NVIC_InitStructure.NVIC_IRQChannelSubPriority =1; //抢占2,子优先级3,组2
NVIC_Init(&NVIC_InitStructure);//NVIC初始化
}
void WWDG_Configuration(void)
{
WWDG_NVIC_Init();
RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE);
WWDG_SetPrescaler(WWDG_Prescaler_8);
WWDG_SetWindowValue(0x5f);
WWDG_Enable(0x7f); //使能看门狗 , 设置 counter .
WWDG_ClearFlag();
WWDG_EnableIT(); //开启窗口看门狗中断
}
//u8 WWDG_CNT=0x7f;
//void WWDG_Set_Counter(u8 cnt)
//{
// WWDG_Enable(cnt);
//}
int main(void)
{
RCC_Configuration();
delay_init(72); //延时初始化
GPIO_Configuration();
LED1=0;
delay_ms(300);
WWDG_Configuration();//计数器值为7f,窗口寄存器为5f,分频数为8
while(1)
{
LED1=1;
}
}
void WWDG_IRQHandler(void)
{
// Update WWDG counter
WWDG_SetCounter(0x7F); //当禁掉此句后,窗口看门狗将产生复位
// Clear EWI flag */
WWDG_ClearFlag(); //清除提前唤醒中断标志位
// Toggle GPIO_Led pin 7 */
LED0=!LED0;
}
为什么我的程序,中断一直进不去啊!只有DS1亮300ms,DS0没反应!求给位帮忙看下程序那里出的问题!
|