This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RTC0 IRQ/event on overflow?

In my project I need to be able to get time from a continuously running RTC. The softdevice uses RTC0, and app_timer uses RTC1 (and starts and stops it).

(annoyingly I have to support nRF51 and nRF52 so I can't just use RTC2)

I've been using RTC0, but of course it rolls over every 512 seconds.

Presumably I can't set up an IRQ because the softdevice does that, but is there some event or callback that I can use to get notified when the RTC has rolled over? Or do I just have to make sure I always wake up after less than 512 seconds so I can check for overflows?

thanks!

Parents
  • I have the same need. I think this is a request for an enhancement to app_timer: even if the app does not have any timers running, app_timer should generate an event/callback when the RTC rolls over so that the app can keep a long-running (64-bit) clock. Lacking that enhancement, as Gordon says, the app needs to always have a timer running with timeout less than 512 seconds. The handler for that timer checks the counter of the RTC to determine whether it has rolled over, and makes appropriate "ticks" on the high order bits of the long running clock. The timer must be for less than 512 seconds else the RTC rolls over twice, missing a tick on MSB of the long running clock. Maybe the request is for a long running clock library that wraps or cooperates with app_timer library. Or the request is for a reference to example code for a long-running clock that uses app_timer.

Reply
  • I have the same need. I think this is a request for an enhancement to app_timer: even if the app does not have any timers running, app_timer should generate an event/callback when the RTC rolls over so that the app can keep a long-running (64-bit) clock. Lacking that enhancement, as Gordon says, the app needs to always have a timer running with timeout less than 512 seconds. The handler for that timer checks the counter of the RTC to determine whether it has rolled over, and makes appropriate "ticks" on the high order bits of the long running clock. The timer must be for less than 512 seconds else the RTC rolls over twice, missing a tick on MSB of the long running clock. Maybe the request is for a long running clock library that wraps or cooperates with app_timer library. Or the request is for a reference to example code for a long-running clock that uses app_timer.

Children
No Data
Related