Skip to main content
andrea2399
Associate
June 8, 2014
Question

STM32F4 Frequency Counter

  • June 8, 2014
  • 2 replies
  • 970 views
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
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
June 8, 2014
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
andrea2399
Associate
June 9, 2014
Posted on June 09, 2014 at 12:49

Thanks, now I will try