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

How to make RTC0 worked in repeated mode?

Hello Nordic support,

I was referring to the RTC example in nrf52 SDK where an interrupt is triggered on Compare Counter event. In the example, the interrupt is triggered just once , i.e 3 s after boot. I would like to modify the example to trigger interrupt every 3 seconds.

To achieve this, I call the function nrf_drv_rtc_cc_set() in rtc_handler as follows:

However, this does not have any effect and the interrupt is triggered only once after boot.

Can you please let me know how to achieve the RTC trigger an interrupt at regular interval?

Thanks,

Anusha

Parents
  • The counter clear operation on the nRF52832 RTC doesn't generate a separate interrupt; and there are 2 other options. If this is the only interrupt used on the timer, you can trigger an overflow, which after 16 RTC ticks will behave as a counter clear and generate an interrupt if enabled.

    If you have more than 1 interrupt in the RTC, then that not may be usable, in which case you can move the CC register forward on each interrupt to the next required value. There are two ways of doing this, read the current counter and add the offset to that or (preferably) add the offset directly to the CC register. The latter option has proved somewhat troublesome on occasion, but worth a try. The former risks losing accuracy as so many cycles are required to read the counter value. The sample code uses direct low-level registers to make clear what is going on; you can translate that the Nordic drivers if preferred.

    The preferred approach:

  • Thanks for the suggestions. I tried the task overflow approach since this is the interrupt I will be using and it is working.

Reply Children
No Data