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

How to use timer to to count periodically

I want to use a timer to get a fixed time interval, so I use a 32-bit timer to count from 0 to 10000, and use PPI to clear the counter when it is captured to 10000, such as:

NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER3->TASKS_CAPTURE[2];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TIMER3->TASKS_CLEAR;

Would it happen that the counter is still counting before the zero clearing operation is completed, resulting in a period of 10002 instead of 10000?

Will this problem still occur if I use the shortcut register?

Is there any other way for me to get an accurate period?

Thanks very much!

Parents Reply Children
Related