cancel
Showing results for 
Search instead for 
Did you mean: 

RTC registers TR and DR gets cleared when coming out of stanbymode

SSmit.13
Senior

Hi

  Im using the stm32L4 , and if not coming out of standby mode I update the time variables. And all works as expected, It  goes into standby mode using the following after a period of time.

 

"HAL_PWREx_EnableSRAM2ContentRetention();

HAL_PWR_EnterSTANDBYMode();"

 

When the processor boots up I check if from standby with the following command

"if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB)!=RESET)"

But calling the above clears the TR and DR registers. Before its executed, there are current date and time within the registers.

Anyone let me know why this is happening?

Cheers

Scott

4 REPLIES 4
Sarra.S
ST Employee

Hello @SSmit.13

"if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB)!=RESET)" wouldn't clear RTC registers, 

As a first step, Read back RRS bit in PWR->CR3 register to check if SRAM is actually retained, and make sure this bit is set ( Read functionnalities depending on the working mode table in the corresponding Reference manual) 

if PWR->CR3.RRS bit is set, check SRAM2_RST bit in Flash register OPTR, this bit needs to be set to prevent SRAM2 erasure after Standby.

This bit can be set either by the Option Bytes with STM32CubeProgrammer ("OB" tab) or in the code.

Hope that helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

> But calling the above clears the TR and DR registers.

How do you know that? How exactly do you observe that?

Also, describe your hardware.

JW

Hi

  I placed the breakpoint on the command , then when I stepped over it , they cleared. I looked on the IDE registers window. The hardware is our own board using the STML433 chip.

 

cheers

Scott

Cheers, will give it a try