2016-09-03 06:52 AM
Hi, i'm studying stm32f407, but there is a problem puzzling methose days. It's about the WWDG.
I just want to test the function of WWDG, so in my function which has been wrote to initialize the WWDG, i enable the WWDG early wakeup interrupt, the function seems as:
void WWDG_Init(u8 tr,u8 wr,u32 fprer)
{
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG,ENABLE);
WWDG_CNT=tr&WWDG_CNT;
WWDG_SetPrescaler(fprer);
WWDG_SetWindowValue(wr);
WWDG_Enable(WWDG_CNT);
NVIC_InitStructure.NVIC_IRQChannel=WWDG_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x02;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x03;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
WWDG_ClearFlag();
WWDG_EnableIT();
}
And in theWWDG_IRQHandler function, the code is:
void WWDG_IRQHandler(void)
{
WWDG_SetCounter(WWDG_CNT);
WWDG_ClearFlag();
LED1=!LED1;
}
Where the LED1 linking a GPIO pin. (P.S. The main function has not been posted)
The problem com
es from theWWDG_IRQHandler function. When i download the code to my board, the led1 blinks very well,which exactly what i'm lookingfor.
But when i exchange the last two lines, namely:
void WWDG_IRQHandler(void)
{
WWDG_SetCounter(WWDG_CNT);
LED1=!LED1;
WWDG_ClearFlag();
}
Then the LED1 won't be blink any more.
I don't know why i just exchange the last two lines will cause the problem, it seems very puzzling.
Can any one help me?
Best regards.
2016-09-03 11:00 PM
2016-09-04 12:32 AM
Hi, obid, thank you very much.
Best regards.