[riot-notifications] [RIOT-OS/RIOT] cpu/kinetis/rtc: add rtc_set_compensation() (#12280)

Thomas Stilwell notifications at github.com
Fri Sep 20 08:21:04 CEST 2019

### Contribution description
This allows configuring the kinetis RTC peripheral to set the fine tuning registers, which is required to bring the accuracy from the order of 10ppm to the order of 1ppm, which ultimately helps achieve the goal of getting the best efficiency out of duty-cycling radio MACs.

All MCUs with 802.15.4 or BLE transceivers will support this feature and at some point there needs to be a standard API for doing this on all platforms but I have no proposal for what that should look like yet. This is just a first step and it would be useful to go ahead and have it in master.

Normally something would periodically call `rtc_set_compensation()` to update the trim based on the current board temperature. However for now I'm just calling it once at boot from `board.c` and this is adequate to improve the accuracy of the RTC from (in my case on kw41z-mini and kw41z-slip) about 6ppm to about 1ppm. Getting much less than 1ppm (or at least guaranteed <=1ppm) requires active temperature compensation and that's why it's needed to have an API to adjust this periodically in runtime.

### Testing procedure
Testing that the compensation is working as intended in an automated way is not entirely trivial. Perhaps we can be satisfied if it compiles and runs without crashing and that I've tested and used it myself.

To test that the RTC compensation is working as intended, call `rtc_set_compensation()` with some chosen values and then let the board run for some days and then compare the RTC against a timebase with preferably 0.1ppm accuracy.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * cpu/kinetis/rtc: add rtc_set_compensation()

-- File Changes --

    M cpu/kinetis/periph/rtc.c (5)
    M cpu/kinetis/periph/rtt.c (5)
    M drivers/include/periph/rtc.h (6)
    M drivers/include/periph/rtt.h (2)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190919/932b040b/attachment-0001.htm>

More information about the notifications mailing list