This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to start and stop a timer in S110?

I use NRF51822 and s110. I want to know how to start and stop a timer, to get the time that the timer run. whitch API should I use int S110?

  • You can get current timer value by triggering CAPTURE task for any Capture/Compare register.

    NRF_TIMER2->TASKS_CAPTURE[1] = 1; // trigger TASKS_CAPTURE for Capture/Compare register 1.
    time = NRF_TIMER2->CC[1]; // Get current timer value
    
  • I want to init a timer by using APP_TIMER_INIT(APP_TIMER_PRESCALER, 2, 4, true); but if I set APP_TIMER_PRESCALER to 0, how many ticks equal to 1s ?

  • There is macro function for this:

    #define APP_TIMER_TICKS(MS, PRESCALER)\
                ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
    

    It'll be 32768 ticks.

  • thank you!