stm32h753 rtc resets after power down (vbat is connected)

Hello,

I am using a stm32h753 and stm32cubemx, and trying to run the RTC module on VBAT. To do this I have connected a battery to the MCU. RTC is connected to LSE. Next, I set the RTC in my code and then I disconnect the MCU from power source, and then reconnect it again. Based on the documentation, this should automatically switch the RTC power source from VDD to VBAT.

I have commented the MX_RTC_Init() in the startup, so that RTC is not reset when the MCU restart.

Below are the code for system clock config, RTC Init, and the code to read the RTC registers after reset.



 When I disconnect the MCU from power source, and reconnect it to power source, the above code gives the following results (RTC register values) after a power reset:

159,10,9,32,51,51,4294967295

So the RTC is reset somewhere in the MCU reset. Considering that I have disabled the MX_RTC_Init(), I do not know where the RTC is reset.

sorry if the question is elementary, I am really new to this field. 

I greatly appreciate any help, thank you.

Best regards,

Vouria

0