2021-12-14 09:16 AM
The data sheet for this part says that after power loss the HT bit is set, and any reads of the clock will return the time of the last read. Then after the HT bit is cleared one should be able to read the current time since the clock is battery backed (a super cap in this case). This works "sometimes", but often the time of the read just before power loss is obtained when the current time should be obtained. Usually there is help on the net, but I have been unable to find a solution. I'm pretty sure there is some trick I'm missing. Since I am unable to find any code examples on the net that try to recover from a power down, maybe you can help with an app note or a code example? AN1572 didn't give much more than the data sheet.
I have included a code snippet which may be helpful.