Electronic – STM32 RTC freeze when power is off

keilrtcstm32

I am using an STM32F745VGT6 user board with Keil µVision 5. I want to use the internal RTC calendar with the internal clock (LSI).

My question is: first power on clock start 02:00:00 then time is going. For example, when time is 02:05:00 suddenly I power off the energy (cut off energy for Vdd, not for VBattery) then wait 10 minutes. After power on, the clock is still 02:05:00. I am stuck. It is so annoying.

I supply to uninterruptible 3.3 volt BIOS battery to STM 6.Pin (VBatt), as in the attached picture. If I remove the battery, each power off and power on start with 02:00:00. So I believe VBatt is working.

Battery circuit

Best Answer

I want to use internal RTC Calendar with internal Clock(LSI).

It's not going to work. From the Reference Manual

4.1.3 Battery backup domain

Backup domain description

To retain the content of the RTC backup registers, backup SRAM, and supply the RTC when VDD is turned off, 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:

  • The RTC
  • The LSE oscillator
  • The backup SRAM when the low-power backup regulator is enabled
  • PC13 to PC15 I/Os, plus PI8 I/O (when available)

The switch to the VBAT supply is controlled by the power-down reset embedded in the Reset block.

Unfortunately the LSI clock is not on the list, that's why it and the RTC stops when VDD is gone.