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

nRF52840 timer that counts to a specific value and wraps up

I'm trying to implement a timer with 1ms resolution that my application can use externally using a callback function.

The idea is to 

  • Implement the timer as a 32-bit counter that counts up starting at 0x00000000 and wraps back to 0 after reaching 0xffffffff.
  • Implement "Atomic" function to return 1ms counter.
  • This atomic function simply returns an uint32_t type variable containing the current value of the counter variable.

I'm a bit lost trying to set up the timer, the SDK examples did not really much help. Could you kindly help me out here with something?

Related