Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to get milliseconds elapsed in a fast, simple method - without APIs.

Hi folks,

I'm receiving a special timestamp over bluetooth, and I want to write it to an external memory. I want the time at which it was written to the memory to be as precise as it can.

I thought of getting the current SysTicks when the message was received, reading current SysTicks again right before writing to memory, dividing the difference by the clock speed, and adding this to the milliseconds value. This way, time can elapse between the receive operation and the write operation, and it will be accounted for. However, I'm finding posts in the forum that show SysTicks aren't really supported by the NRF5 sdk on the NRF52840. Are there any registers I could access to get some sort of "tick", and the current clock speed (in case the nordic is running on the low frequency rc clock), so I can divide the two and get a "time elapsed"?

Cheers and all the best!

Parents Reply Children
  • well SysTick only counts when the CPU is running, so in any mode you'd usually want to use a Nordic chip in, which is 'sleep as much as possible', it's not ticking fairly often. I'm assuming that's what the OP is referring to although if they are doing these measurements in code they can be sure is constantly executing .. SysTick will be counting, although possibly at the internal RC frequency. 

Related