cancel
Showing results for 
Search instead for 
Did you mean: 

Putting STM32F437xG into Standby mode more than once

Rob Meades
Senior
Posted on November 22, 2017 at 12:46

I have some code which puts my STM32F437xG into Standby and wakes it up on RTC.  In my test code this works fine: I can go into Standby for, say, 10 seconds (enabling just the battery-backed RAM, flash is off), return at reset, go back into Standby, wake up 10 seconds later, and repeat ad infinitum.

I have now integrated this code into my main application and I find that I can go into Standby successfully but, once I have returned from Standby, I can no longer go back into Standby successfully again; something is waking me up immediately, returning at the reset vector, rather than waiting for the RTC alarm I have set to wake up.

I have checked that, when I attempt to go back into Standby, no interrupts other than RTC are enabled, the PWR_CR_CWUF flag is cleared and the previous RTC alarm has been reset with:

RTC->ISR &= ~RTC_ISR_ALRAF;

RTC->WPR = 0xCA;

RTC->WPR = 0x53;

RTC->CR &= ~RTC_CR_ALRAE;

RTC->WPR = 0xFF;

EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT;

What else could be causing the MCU to wake up again immediately?  How can I find out what's causing the wake-up?  FYI, battery backed SRAM is being maintained correctly and none of the RCC flags (RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_PINRST, RCC_FLAG_LPWRRST) are set on return from reset.

Rob

1 REPLY 1
Rob Meades
Senior
Posted on November 22, 2017 at 17:53

Fixed it!  I was being an idiot: my sleep time was in seconds my sleep function takes milliseconds.  Everywhere else I was multiplying by 1000, just not in this one case.  Nice to have a simple one...