This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to use the timer capture ?

hi,

i want to use 51822 timer counter to capture external pulses,how can i config the capture task?

in the nRF51 Series Reference Manual, it is say

The TIMER implements one capture task for every available capture/compare register. Every time the CAPTURE[n] task is triggered the Counter value is copied to the CC[n] register.

  • You cannot read the active counter value of the TIMER module like you can do with RTC. That is why CAPTURE TASK was created. If you want to read the current counter value of say TIMER1 into CC[2] for example what you do is

    uint32_t   current_counter = 0;
     NRF_TIMER1->TASKS_CAPTURE[2] = 1;  // This is asking to capture the current counter into CC[2]
    current_counter = NRF_TIMER1->CC[2];   // counter value  at the instant when capture task was triggered is now ready to be read in CC[2]
    
Related