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

how can i use timer as counter??

Hi, i need to calculate the frequency of two PWM.

When it comes to frequency calculation, the counter function is the best solution, i think.

i'm using SDK 6.0.0 for my project.

i tried to calculate the frequency by timer. but the 'APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER)' can make 1ms timer interrupt as a minimum clock.

actually, the highest PWM frequency is up to 5kHz so, 1ms timer interrupt is so slow to capture the 5kHz PWM

  1. how can i get some example about counter??
  2. or how can i make more faster timer interrupt??

thanks!

Parents
  • Much smarter than my previous answer, don't know what I was thinking, but the concept is almost the same.

    Use gpiote with event on rising edge, connect the event to timer start with ppi, connect falling edge gpiote event to timer stop and read the value. You can also connect the same event (stop event) to timer capture so the timer value resides in a CC register until you clear it.

Reply
  • Much smarter than my previous answer, don't know what I was thinking, but the concept is almost the same.

    Use gpiote with event on rising edge, connect the event to timer start with ppi, connect falling edge gpiote event to timer stop and read the value. You can also connect the same event (stop event) to timer capture so the timer value resides in a CC register until you clear it.

Children
Related