Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Sistick timer extension in nRF5 SDK

Dear DevZone, 

I am investigating the possibility to use the sistick hw timer in a nr5 SDK v15.3 project, running on a nrf52840 uC.

My final goal would  be to print a timestamp in a log file. However, the documentation clearly states that the timer resets after 250ms:

This library configures SysTick as a free-running timer. This timer is used to generate delays and pool for timeouts. Only relatively short timeouts are supported. The SysTick works on 64MHz and is 24-bits wide. It means that it overflows around 4 times per second and around 250 ms would be the highest supported time in the library. But it would be really hard to detect if overflow was generated without using interrupts. For safely we would limit the maximum delay range by half.

My question is: 

Is there any way to extend this interval to much higher values?

Thank you very much in advance, best regards


  • Hi Gianluca,

    There is not much you can do with that. However, for the use case you describe I would normally avoid the systick timer. Instead, the allmost all applications use an RTC for the app_timer library, and then you could instead make sure you set APP_TIMER_KEEPS_RTC_ACTIVE to 1 in your sdk_config.h. That way the app timer always runs, and you can use that to keep track of time.

    You still need to handle wrap-arounds though, as that is not handled by the app timer. Alternatively, if useing the app_timer2 implementation, you could hook into the internal 64 bit counter, which in practice will never wrap around (see this post).