[feature-hal-spec-rtc] Improvements to RTC HAL API

24 Mar 2018


Real time clock is a fundamental building block of an embedded systems. It enables the hardware to track current time. The RTC hardware is used to retarget the C standard library time functions. Additionally, there’s a number of Mbed OS APIs building on top of the RTC:

What we've done

  • Updated specification for RTC API including defined behaviours
  • Revised porting guide in the reference book
  • Created a validation test suite

What has changed?

API remains the same, but we've created a specification and validation test suite for this peripheral. The feature branch passes all testing which means that targets capable of RTC but failing the test suite have had RTC removed from the device_has field in targets.json. If you are interested in contributing platform support, you can check out the feature-hal-spec-rtc branch, add RTC to the device_has list in targets.json and run

mbed-os> git checkout –b feature-hal-spec-rtc origin/feature-hal-spec-rtc
mbed-os> mbed test -t <toolchain> -m <target> -n "tests-mbed_hal-rtc*"

Who is affected?

All targets will need to be updated to conform to the new specification and pass the validation tests to claim RTC support. While the API has not changed, the defined behaviours have. For example, according the revised specification the RTC must keep time across reset. This is particularly important for products that will be remotely managed. From a brief investigation there are a few MCUs and boards that will not be capable of this requirement.

  • Nordic nRF51 and Nordic nRF52 – Software reset will reset the RTC. Off mode reset can be used as an alternative and will not reset the RTC:

When will it happen?

The development branch is available now for contributions. We are planning to bring the changes to master in Mbed OS 5.9 release. The expectation for completion is that 80% or more of the targets capable of the RTC specification support the new API. Contributions are welcome!