cancel
Showing results for 
Search instead for 
Did you mean: 

TIM14 Period Measurement

johnsotack9
Associate II
Posted on December 22, 2014 at 17:36

I have an existing STM32F407 family target that has a pulsed signal at PF9.  I need to measure the period of this signal.  This signal has a fixed low time followed by a variable high time.  PF9 can serve as an input to TIM14.  Ideally I would like TIM14 to count up based on an internal clock, capturing and clearing the count on an edge of PF9 (rising or falling but not both).  The firmware would read the captured value for each cycle.  TIM14 would count based on an internal clock.  Any suggestions?  Is this possible with TIMN14.  I known TIM9/12 can measure PWM high and low times.  My need is not to capture both as with PWM input, but a single period.

Presently I have an ISR attached to a falling edge of PF9.  If necessary, I would read the contents of any freer unning timer each time the interrupt occurs and calculate the timer difference.

0690X00000605DiQAI.png 
2 REPLIES 2
Posted on December 22, 2014 at 17:44

Doesn't PWM Input allow you to measure both period and duty using two channels (paired from a single input), and a single interrupt?

Not that it is materially different from input capture and computing a delta, the PWM Input typically resets the counter.

If interrupts are unappealing, DMA could be used to take sequential period measurements.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
johnsotack9
Associate II
Posted on December 22, 2014 at 19:07

TIMS 9/12 will do the PWM input.  They have two timer captures and that may be why.  TIM14 does input capture and has a single capture register.  There may well be a way to do a single repetitive period measurement with TIM14 although there does not seem to be a direct example where the count gets cleared to zero after each capture.  If I have too, I can use my existing interrupt handler to read a second free running timer I set up.  That may add some jitter because another interrupt may or may not occur at the same time.