2014-05-21 12:28 PM
hello forum ,
I want count the time between the rising and falling edges of a 100 Khz square wave with STM32F4 timer now as the timer counts with 168 Mhz ,what can be the minimum count between the two very close measurements ?is it 1 count or more than 1 count ?I mean what is the granularity of timer capture function ?thank you #stm32f4-timer2014-05-21 12:37 PM
The counters for a 168 MHz F4 part are 84 MHz for APB1 counters, and 168 MHz for APB2 counters. You can make it more course with a prescaler.
The latching will resolve to a single tick, your issue will be interrupting, and how that saturates the processor. You can count pulses over a period. You could also use PWM Input mode where the HW captures the measurements, and you get to them when you can. Perhaps you could capture with DMA?2014-05-21 01:19 PM
hello clive , you gave me an idea
If I have 100 KHz %50 duty square wave with 168 Mhz counting timer I can measure 840 count if the frequency drops to 95 Khz I measure 884 countthere is 44 count inbetweenthis precision is unsufficient for memy questionIf I take 100 following measurements and average to a floating variable can I get something like 870,46 ( this is mathematicaly true value ) for example for 96.5 Khz ?does the ''nature'' help me here to increase the precision ?this is my best english hope you understand what I mean thank youPS. I dont need interrupt at every mesaurement - I only need the above capture value every milisecond for example2014-05-21 02:03 PM
You have a resolution of ~6 ns (168 MHz) or ~12 ns (84 MHz)
You could use a prescaler on the Input Capture, and time over say 8 periods TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV8; freq = (168000000 * 8) / ticks