AnsweredAssumed Answered

A confused problem about WWDG_IRQHandler

Question asked by wang.gaoteng on Sep 3, 2016
Latest reply on Sep 4, 2016 by wang.gaoteng
Hi, i'm studying stm32f407, but there is a problem puzzling me those 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 the WWDG_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 comes from the WWDG_IRQHandler function. When i download the code to my board, the led1 blinks very well,which exactly what i'm looking for.

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.

Outcomes