Hi,
Is this the right way of reading the timer value using the capture task. In this code i am trying to read the updated value of counter for every event generated in the interrupt handler.
> int main() {
> NRF_CLOCK->TASKS_HFCLKSTART = 1;
> NRF_TIMER2->BITMODE = 03ul << 0ul;
> NRF_TIMER2->MODE = 0ul << 0ul;
> NRF_TIMER2->TASKS_CLEAR = 1;
> NRF_TIMER2->CC[0] = 1000;
> NRF_TIMER2->PRESCALER = 9;
> NRF_TIMER2->INTENSET = 1ul << 16;
> NVIC_EnableIRQ(TIMER2_IRQn);
>
> NRF_TIMER2->TASKS_START =1;
> NRF_TIMER2->TASKS_CAPTURE[1] =1;
> NVIC_SetPriority(TIMER2_IRQn, 3);
> }
> void TIMER2_IRQHandler(void)
> {
> if (NRF_TIMER2->EVENTS_COMPARE[0] !=0)
> {
>
> NRF_TIMER2->EVENTS_COMPARE[0] = 0;
>
> count = NRF_TIMER2->CC[1];
>
> }
>
>
> }
What i am getting is the same count value everytime the interrupt is called. Is this the right behavior or am i missing anything?