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?

Parents Reply
  • Hi  , 

    Thanks for the response, I checked it out. However because of limitations with the project I'm not using zephyr or even the nRFConnect SDK, the development is being done bare metal on the PCA10056 board of the nRF52840, using nRF_SDK_15.3.0

    Accordingly, I'd only be able to use the nRF SDK 15.3.0 files to implement this funcitonability.
    I figure, I can set up a timer of 1ms, that as a timer event increments a variable and I can just read the variable and return it. I dont understand the NRF_TIMER_EVENT_COMPAREX modes and also the NRF_TIMER_SHORT_COMPAREX_CLEAR_MASK modes.

    Would there be an easier method of implementing what I require using the SDK files only?

Children
Related