cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I'm using the MCU STM32l476, and I have a problem with RTC. The RTC works only if the board is turned on. When the board is turned off or it's sent a command to the MCU go to shutdown mode, the RTC is reset to zero values.

FDigi
Associate III

According to the datasheet, there is shutdown mode with and without RTC, so I believe it's a problem of configuration. Can be some parameter of configuration that is missing? How to configure the shutdown mode with RTC?

Thanks!

12 REPLIES 12
Piranha
Chief II

Which oscillator are you using for RTC? In shutdown mode RTC can work only with LSE, not LSI.

FDigi
Associate III

I'm using the LSE oscilator.

And what happens with RTC if you reset the board either by pulling the NRST pin down, or in software, i.e. without turning the power off?

JW

Piranha
Chief II

Also an idea.. Maybe you are reading RTC incorrectly? RTC has a special procedure for reading and setting date/time values. Looking with a debugger will not show these registers correctly.

> Looking with a debugger will not show these registers correctly.

The lock/unlock mechanism with BYPASS=0 may surely be confusing, but should not result in reading 0.

OTOH, reading after startup may indeed return 0, if the synchronization mechanism indicated by RSF bit is not observed. Nevertheless, the proper procedure to read time/date is described clearly in the Reading the calendar subchapter of RTC chapter of RM.

JW

For reading I'm using the functions HAL_RTC_GetDate() and HAL_RTC_GetTime(). For setting HAL_RTC_SetDate() and HAL_RTC_SetTime()

Jack Peacock_2
Senior III

Do you have a backup power supply connected to the VBAT pin? One that remains on when you turn off power to the board?

Yes, I have a backup supply connected to VBAT pin.

And what happens with RTC if you reset the board either by pulling the NRST pin down, or in software, i.e. without turning the power off?

JW