[Enhancement] Add date retention functionality for STM32F1xx based boards#41
[Enhancement] Add date retention functionality for STM32F1xx based boards#41josh-gaby wants to merge 12 commits intostm32duino:mainfrom
Conversation
Add date retention functionality for STM32F1xx based boards
Remove spaces to pass AStyle check
|
Hi @josh-gaby |
Only run RTC_StoreDate from the SetDate function if running on stm32f1xx
Store the date after a rollover on power up or it will revert if power is lost again before manually changeing or another rollover occurs.
Add a backup register definition
Fix code styling
Correct backup register
Retain weekday through power cycle
Add check for valid weekday when restoring date
Fix typo
Include missing header file
|
Hi @josh-gaby
I think using epoch time to restore the date is a better solution and will cover all the case. |
|
Thanks to a "magic nb" in another backUp register, there is a simple way to detect if the Vbat was powered during Vdd OFF. |
|
This proposal looks like a custom appli as long as only the date is kept (stored) on each call to rtc.setDate. On the stm32F1 there is one-second interrupt (see #57) that could help storing the new Date and/or Time in BackUp Registers. |
|
Its been awhile since I've had a chance to work on this, I will try and get back on it this weekend. |
|
I just ran into this, would be awesome to get this fix across the line and merged. |
|
I close this PR as it is superseded by #58. |
Adds date retention through power cycles on stm32f1xx based boards
On these chips, the date details are only stored in SRAM while running, because of this, dates are not being retained after a power off even with VBAT connected.
This is fixed by using backup registers DR2 and DR3 to store the date data each time it is updated. Doing this means that the date can then be extracted and set correctly when the RTC is next initialized.