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

how to use rtc in nrf52840 dongle

Timer A with a 10-minute interval, timer B with a 4-hour interval, and timer C with a 10-second interval are required, and A and B should also run out of time in low power mode. Timer C only needs to flow for 10 seconds and remains (while generating a BLE signal) while the CPU is fully awake.

If I use softdevice, it says I can't use RTC0, is this right?
Then can I use timer A as RTC1 and timer B as RTC2?

Can I use two RTCs with different scale values?

I understand that APP_TIMER uses RTC1. Then should I not use APP_TIMER in my case?

Can I use TIMER using HFCLK for Timer C?

Parents
  • Typically the timeout needs to be set such that the RTC doesn't overflow, and depending on the prescaler value that may happen after 512 seconds. In your case I would have setup a timeout value of 60seconds and use a counter that increments, something like:

    static uint32_t counter;

    1minute_timeout_handler()
    {
    counter++;
    if(counter%10 == 0)
      10minute_timeout_handler();
    if(counter%240 == 0)
      4hours_timeout_handler();
    }

    Best regards,
    Kenneth

Reply
  • Typically the timeout needs to be set such that the RTC doesn't overflow, and depending on the prescaler value that may happen after 512 seconds. In your case I would have setup a timeout value of 60seconds and use a counter that increments, something like:

    static uint32_t counter;

    1minute_timeout_handler()
    {
    counter++;
    if(counter%10 == 0)
      10minute_timeout_handler();
    if(counter%240 == 0)
      4hours_timeout_handler();
    }

    Best regards,
    Kenneth

Children
Related