Frequency measurement with STM32

frequency-measurementstm32timer

This question is mainly a query for an advice.

I am trying to implement a frequency meter on STM32F4.
Up to this point I have a working ADC converter with DMA and a timer which checks for the current voltage value and catches a zero crossing (with margin) and counts the counter.

Now, what is the best way hot to determine the actual frequency? In sense of – shall I rely on timer clk speed or should I use RTC?

Or is there a better way how to determine the frequency?

Best Answer

I would use a zero-crossing detector circuit (google - tons of them, very easy) and then (depending on the frequency you're trying to measure) either use an input-capture timer/counter to automate the counting, simply reading & resetting the count at given measurement intervals (much lower CPU load), or use the input pulses to gate a fast counter (to count a LOW frequency) and calculate the inverse (for low frequencies it's easier to measure the time taken per pulse rather than pulses accumulated per time period).

Either should leave your CPU with very little hard work to do.