cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Frequency Counter

andrea2399
Associate II
Posted on June 08, 2014 at 19:21

Hello everyone, i'm using the CCP module in ''PWM input mode''. My goal is to measure the frequency, the period and the duty cycle but the measure isn't precise, it continually changes near the true value. This happens only with frequencies higher than kilohertz. I'm using the ''Peripheral_Examples'' code: TIM_PWM_Input that ST has released in ''STM32F4-Discovery_FW_V1.1.0'' file. Can someone help me? thanks and sorry for my bad english

#pwm #input #discovery #stm32f4
2 REPLIES 2
Posted on June 08, 2014 at 20:34

With higher frequencies the granularity of the timer, and the ability to saturate the processor become bigger issues. The granularity will be worsened by having a prescaler other than zero (DIV1). Ideally you should use a timer on APB2 clocking at 168 MHz, these will all be 16-bit timers.

One might address this a couple of ways

a) use DMA to capture a list of time stamps in Input Capture mode (not PWM Input). One or Both Edges.

b) use IC Prescalers (DIV8), not to be confused with the TIMEBASE Prescaler

c) counting external pulses, integrating over time, ie ticks per millisecond. Gating the timer, or snap shot with DMA
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andrea2399
Associate II
Posted on June 09, 2014 at 12:49

Thanks, now I will try