cancel
Showing results for 
Search instead for 
Did you mean: 

how to restore date/time in RTC with the backup battery connected.

MNapi
Senior III

I do have time working but it will reset each time when I power it off. I do have the backup battery connected.

I thought that it is supposed to keep working on battery and I guess it does.

But I guess I might be missing a few lines to read registers and update the time once power in back on.

14 REPLIES 14
MNapi
Senior III

I am trying your code but I do not know where rtc_state is coming from, it says undeclared identfier

Piranha
Chief II

All of these "restoring" ideas and magic values is a complete nonsense. Instead just read the following Jan's articles:

http://efton.sk/STM32/gotcha/g116.html

http://efton.sk/STM32/gotcha/g123.html

I use it for traceback RTC initialize step on every each restart.

I just don't want to debug for every time of reboot it.

Thanks for the code, I did not have to change anything just a few new lines. I did not noticed that opening and closing curly bracket are in the user code area and I thought that it would reset the clock each time.

I checked. it works fine the time still counting after power off/on

Actually all you had to do is just check a single bit as written in the links presented below.