Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTC irq_handler potential problems

The RTC irq_handler of the latest nRF5 SDK may cause potential problems.

Imagine someone trying to extend the RTC timer from 24bit to 32bit, the developer has to keep an extra byte and increment the overflow on overflow event.

The current implementation irq_handler fires COMPARE event before fires OVERFLOW event, which potentially may cause failure for timer longer than 512 seconds.

It may happen only if the code happens to be waiting on comparison of 0!

I would suggest a code change on your side. As a safe guard, I will check NRF_RTC_EVENT_OVERFLOW in my code on compare and perform increment and clear event.

Also, I would like a confirmation from your hardware team, that if the code is waiting on tick 0, the OVERFLOW and COMPARE event will be guaranteed to be fired together, or at least OVERFLOW shall be fired before COMPARE.

Cheers

Qingjun

  • Hi Qingjun,

    Thanks for your feedback, I have forwarded it to our development team and they will take this into account on any future refactoring of the driver. Regarding OVERFLOW and COMPARE events, from software perspective they occur at the same time (by the time irq handler is executed both will be set), but we haven't check the exact timing of the hardware events. 

    Best regards,

    Marjeris

Related