Open richarthurs opened 7 years ago
We also need a RTOS task that will periodically (once every few seconds) check to see if the current RTC value is greater than the previous RTC value. If not, enter SAFE mode. It should also check RTC registers for failure.
Pseudocode:
Similar to the task above, which is basically a constant sanity check that will be run, we need a simple test suite for the RTC.
It should:
The RTC has a lot of bits that can be checked to determine if it has lost power or undergone a reset for some other reason. It can also provide an estimate if time data has been corrupted.
rtc_get_startup_status() needs to be fleshed out to log errors, and another function that periodically checks the status of the RTC needs to be created.
Resources: [1] http://www.abracon.com/realtimeclock/AB-RTCMC-32.768kHz-EOA9-S3.pdf [2] http://www.abracon.com/realtimeclock/AB-RTCMC-32.768kHz-EOA9-S3-Application-Manual.pdf
Bits that should be checked: CTRL_STATUS -> PON (1 = time might be bad) CTRL_STATUS -> SR (1 = time might be bad) CTRL_STATUS -> V2F (1 = time might be bad) CTRL_STATUS -> V1F (1 = time might be bad) CONTROL_INT FLAG -> V2IF (1 = time might be bad) CONTROL_INT FLAG -> V1IF (1 = notable event, but time is ok)
These bits should be set for configuration at startup: CONTROL_INT -> SRIE = 1 CONTROL_INT -> V2IE = 1 CONTROL_INT -> V1IE = 1 CTRL_STATUS -> PON = 0 Assert a system reset [2 - page 24] at first power on (PON = 1)