cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Value being lost on Sleep mode

andre239955
Associate
Posted on June 21, 2010 at 17:23

RTC Value being lost on Sleep mode

3 REPLIES 3
Posted on May 17, 2011 at 13:55

The problem is likely how you are initializing the RTC when the system exits STANDBY. You need to check and clear the PWR_FLAG_SB, and you should be able to recover the time from RTC_GetCounter() and not reconfigure the RTC.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
damh
Associate II
Posted on May 17, 2011 at 13:55

Sleepmode and standbymode are extremly different on the STM32!

After wakeup from standbymode, there will be a reset. RAM content is normally lost.

If LSEON, LSERDY, RTCON, ... are in correct state, you have the possibility to recover the RTC. You have to reset the ''Registers synchronized flag'' and wait until it is automatically set again. This operation is slow (>30µs). You can write to the RTC registers before, but reading brings wrong values, because the shadow registers in the interface aren't initialized.

gil2
Associate II
Posted on May 17, 2011 at 13:55

Mine does not wake up from Standby.

I currently do it like this:

...

   // Peripheral Clock - This is done in the init function, but I did it again here

   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);

  

   // Enable WKUP pin

   PWR_WakeUpPinCmd(ENABLE);

   // Insert a delay  - I have also tried without this delay

   Delay(0xFFFF);   // for(; nCount != 0; nCount--);

   // Request to enter STANDBY mode and wake up with rising edge of WKUP pin  

   PWR_EnterSTANDBYMode();

   while(1)  

   {  

     // Infinite loop - It's OK because the system will reset anyways  

   }  

The unit does not wake up (reset).  I've tried with both the JTAG connected and not connected.

Port PA.0 (WKUP pin) has a pull-down resistor, leading to a momentary switch, with Vcc on the other side of the switch, which should be enought to generate the required rising edge when the button is pressed.

Any ideas?  Thanks!