cancel
Showing results for 
Search instead for 
Did you mean: 

Immediate exit from stop mode one interation after RTC periodic wakeup

Ernest Lotter
Associate II
Posted on February 01, 2018 at 21:57

I am using a STM32F427 MCU and have trouble understanding the stop mode behaviour I am experiencing.

I use the RTC periodic wakeup event to wake from stop mode (WFE - using event only). 

The the correct EXTI line 22 configured for RTC wakeup event the sequence is as follows:

------------------------------------------

Loop:

   (1) Configure RTC wakeup clock and set counter (e.g. 2 seconds)

   (2) Clear RTC wakeup event flag 

   (3) Clear related PWR wakeup event flag

   (4) Enable RTC wakeup

   (5) request stop mode (WFE)

    if (RTC wakeup flag status != true)

        exit loop // Accelerometer or something else must have triggered wake so lets start RTOS...

   else

       do a few things (e.g. check a few analog readings)

  

--------------------------------------------

The issue is that when I 'do a few things' after exiting from stop mode after initial RTC wake and it takes too long (too many instructions) then it, on the next iteration, exits from stop mode immediately, BUT it does NOT read the RTC wakeup flag status as true and therefore exit the loop as if something else caused an event. The problem is the RTC as well as the related PWR wakeup flag are not set! Also all other interrupts at this stage are masked out. When there is no ocde in the else statement, or just a few tiny instructions, it correctly reads the RTC wake status flag as true and remains in the loop as expected. 

I do not understand this behaviour and I am hoping someone can explain why this may be happening or perhaps even be expected behaviour?

#wfe #stop-mode #stm32f4-rtc-wake #wake #rtc-wakeup-event
0 REPLIES 0