cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Capture for frequencies < 100Hz

Rogers.Gary
Senior II
Posted on February 03, 2015 at 02:20

Hello,

I am endeavoring (as with every hair-pulling experience with the STM32F4) to measure/capture LOW frequency pulses. For this, I'm assuming I need to use a 32 bit timer: TIM2 or TIM5.

This is a bit of a dilemma since TIM2 or TIM5 do not have a capture compare. So how to measure low frequency pulses?

Thank you....

#stm32f4-timer-capture-compare
12 REPLIES 12
Posted on February 04, 2015 at 00:53

Regarding your suggestion, about delta measurements, you said to take 2 of them and subtract (2nd - 1st)  But separated by what interval of time?

Two edges of your input signal, it's what the states in your pasted code do, but trying to bring some clarity.

The whole bigger/smaller code is a jumble, for 16-bit and 32-bit unsigned you can just let the processor do the math, the wrapping of the arithmetic will handle the wrapping of the counter.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Rogers.Gary
Senior II
Posted on February 04, 2015 at 01:04

Ok - I thought you were referring to something different than what was in the function pasted.

I'm actually using the function to read a signal that's more like a sine wave, periodic in nature. It seems to capture good, considering the signal. I may end up buffering through a Scmitt trigger to give it more of a pulse, but for now it should work.

I found that changing the filter from 0x0 to 0xf made some difference, depending on the amplitude of the signal. I'll need to read on that to see exactly what it does and what kind of signals it is designed for.

thanks clive1.

Rogers.Gary
Senior II
Posted on February 04, 2015 at 01:17

I checked the manual out. Looks like the filter might come in handy for what I'm doing.

I am transmitting a finite number of cycles at a given frequency, and it seems the filter can be programmed to ''validate'' after reaching the programmed number of captures - in powers of 2. A value of 0x3 = 2^3 = 8 cycles, which would be a good number to start with in my application. Awesome stuff.