RTC in STML151 always resets to default after watchdog reset
Hi there,
I want the calendar/clock to retain its value after a watchdog or other non-power-on reset.
Here is my code, near the beginning of main.c:
// and same for the real time clock, but don't intialise it unless it's a power-on reset
if (LL_RCC_IsActiveFlag_PORRST()) {
MX_RTC_Init();
}
// update the RTC shadow registers in the event it's not a power on reset and we need the existing calendar values
hrtc.Instance = RTC;
HAL_RTC_WaitForSynchro(&hrtc);
// clear the reset flags
LL_RCC_ClearResetFlags();In my MX_RTC_Init function (as generated by Cube) I set the year to 2005 as a debugging aid.
Later in my code I set today's date and time, and can read this back OK.
After a watchdog reset, the MX_RTC_Init function does NOT get executed, but the RTC gets set to the default calendar of year 2000 etc.
Many thanks for any help on this one,
Steve
