cancel
Showing results for 
Search instead for 
Did you mean: 

Internal RTC resetting on shutdown mode

BKrug.1
Associate II

Hi, I have a device using an STM32U575 and I'm using the internal RTC to keep date and time, due to it being battery operated it goes into shutdown mode for most of it's operating time. The problem I'm having is that the RTC loses it's date and time values in shutdown mode, I tested putting it in standby mode and everything works.
The datasheet and reference manual both say that as long as the clock source for the RTC is the LSE, it should keep working even in shutdown mode, so I'm really confused with this behavior.
I'm still testing a couple of things to see what could be missing/added, as it is a very complex project and someone in the team might have added a line somewhere they shouldn't have or something like that.
Note.: I can give bits and pieces of the code pertinent to the RTC, but cannot give too much of the code due to it being from work.
Any help you can give will be very appreciated. Thank you in advance.

8 REPLIES 8
Sarra.S
ST Employee

Hello @BKrug.1 

Please check the BDRST bit in RCC_BDCR, this bit should be set to 0 so the reset of RTC is not activated 

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.

Is there a specific point in the code I should set this bit to 0? I tried putting it right before going into shutdown and right before starting the RTC and didn't change the behavior.

BKrug.1
Associate II

I made the device print the whole BDCR right before goind into shutdown mode, this is the result:
0000 1100 0000 0000 1000 1001 1001 1011
So from this, the configuration as a whole does seem to be correct

BKrug.1
Associate II
Through testing a bit more, I found out that by connecting VDD to VBAT the problem is solved, although ideally I need a software solution if possible, as we now have quite a few boards we would need to make the connection manually to make them work.
Sarra.S
ST Employee

Hello @BKrug.1

I thought you had already powered VBAT (sorry for not asking) 

To retain the content of the RTC backup registers, backup SRAM, and supply the RTC when VDD is turned off, the VBAT pin can be connected to an optional standby voltage supplied by a battery or by another source.

To allow the RTC to operate even when the main digital supply (VDD) is turned off, the VBAT pin powers the following blocks: (refer to the datasheet)

 

SarraS_1-1699872617773.png

 

 

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.

The VDD never gets turned off in my circuit, the MCU simply goes into Shutdown mode. Do I need to connect the VBAT pin for the RTC to work in shutdown mode? This is never specified on the datasheet or at least I could not find it.

Sarra.S
ST Employee

Hello @BKrug.1

The Vbat pin needs to be powered to preserve the content of backup registers. it can be powered either by VDD or an external battery. 

As mentioned in AN5373- Power supply schemes: If no external battery is used in the application, it is recommended to connect the VBAT pin to VDD with a 100nF external ceramic decoupling capacitor. 

 

it worked in standby mode because the switch between VDD and VBAT is controlled automatically by the brownout reset circuitry or the BOR is not available in Shutdown mode.

 

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.

Is there anyway to control this switch between the VDD and VBAT through software? That way I could connect them before going into shutdown mode.