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
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.