SFUSatClub / obc-firmware

Firmware for our cubesat's On-Board Computer using the TMS570LS0432 and FreeRTOS v9
18 stars 3 forks source link

RTC Error Checks and Tests #21

Open richarthurs opened 7 years ago

richarthurs commented 7 years ago

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)

richarthurs commented 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:

richarthurs commented 6 years ago

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: