-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
ports/nrf: Add RTC support to NRF ports. #14198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: RetiredWizard <github@retiredwizard.com>
Signed-off-by: RetiredWizard <github@retiredwizard.com>
Signed-off-by: RetiredWizard <github@retiredwizard.com>
@cwalther I was thinking about the offset check from my PR and was wondering if it's a carry over from the IMX boards that support an RTC battery to keep the clock running when the rest of the board is shutdown. I don't know if the nrf boards have any similar capability. |
Found it. The validation thing is from adafruit#2924 and the purpose is indeed to maintain the clock over certain kinds of reset that clear the BSS section but not all of RAM (not a MicroPython soft reboot, that is already achieved by my approach). However, the parts of it that are in this PR are not sufficient to make this work, adjusting the linker scripts and heap initialization for setting up the I am undecided whether this is a desirable thing, so I will not add it to #13340 for now. It is useful in some cases, such as an unattended device in the field that occasionally crashes and is restarted by a watch-dog timer. On the other hand, it is a complication and violates the expectation that a reset resets everything. |
Thanks! Great detective work! |
I had to add MICROPY_PY_MACHINE_RTC_ENTRY to the MICROPY_PY_MACHINE_EXTRA_GLOBALS marco to make RTC show up in the machine module time.localtime() and rtc.datetime() are not in sync. time.localtime(time.mktime(machine.RTC().datetime())) works Thank you for your work! |
Resubmitting after accidentally closing #10400
Updated after reviewing RTCounter.py. It turns out that RTCounter starts up and uses the second nrf rtc unit so piggybacking off of that this update doesn't need most of the Circuitpython logic the earlier PR was using and takes care of starting up the rtc which had been omitted.
Since RTCounter uses rtc unit 1 this PR compiles on all of the currently supported nrf series boards.
This is the same update as the accidentally closed PR but there is an alternate version to evaluate as well #13340.
Signed-off-by: RetiredWizard github@retiredwizard.com