← index #1509PR #12482
Related · high · value 0.619
QUERY · ISSUE

RTC initialisation and wakeup from external events

openby peterhinchopened 2015-10-13updated 2015-10-25
ports

If the Pyboard is woken from standby by the tamper pin X18, the RTC is reset to 1st January 2014 regardless of any setting performed in code.

It appears impossible to prevent this from Python as it occurs in rtc_init() which is called from main.c. The problem occurs because rtc_init() checks backup register 0 for a specific value 0x32f2 to see if the RTC has already been set. If the value is not correct it assumes the Pyboard has been powered up, sets the RTC to that date, and sets the value of backup register 0 to 0x32f2 to ensure that the RTC continues to run through reset events.

Unfortunately the tamper pin clears the backup registers, so on recovery from standby rtc_init() runs again, detects that the register does not hold 0x32f2 and resets the RTC.

I have produced a build where RTC initialisation occurs in the constructor. This has a boolean argument defaulting True: if present and set False, initialisation is inhibited. This allows the user to take control of the detection of boot events and initialisation of the RTC (power up can be detected by checking the contents of backup RAM which are unaffected by tamper events).

If the argument is absent or True initialisation and boot detection work as at present so existing code should be unaffected.

If this approach meets with approval I can submit a PR.

CANDIDATE · PULL REQUEST

mimxrt/rtc: Improve the RTC initialisation during start-up.

mergedby robert-hhopened 2023-09-19updated 2023-10-02
port-mimxrt

It solves a problem, that the RTC may stop running on battery power after the battery was low and the board not powered.
Following PR 7463 from the CircuitPyhton repository.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied