cancel
Showing results for 
Search instead for 
Did you mean: 

Maximum reasonable Frequency for TIM2 Frequency counter measurement?

David Pekin
Senior

Hello,

We're looking at using a STM32F303RE for a project. One of the requirements is being able to measure the frequency of a square wave ranging from 1MHz - 40Mhz. I've been looking at the General-purpose timer cookbook (AN4776) and trying to get the frequency counter sample application working on the F303 platform but have so far been unsuccessful but that's another issue.

However, as I become more familiar with the way that code works, I'm concerned that it won't work at these higher frequencies. if the system clock is 72MHz, trying to count the CC2R clock counts latched at 40Mhz will only give counts of 1 or 2, right? I guess we could build a divisor circuit to condition the input signal down from 40Mhz by a factor of 16 or 32?

Any thoughts on this? Am I missing something?

Thanks

11 REPLIES 11

Hello

" In order to get a frequency resolution of 0.1 Hz you need to count pulses for 10 seconds."

You are right. I would like to add something.

Let suppose that we use a 50 ppb 10 MHz OCXO as oscillator, to create the period of 10 sec. Is this resolution 0.1 Hz (1 LSB of counter measured value), the maximum we can get from this?

The answer is no.

In this case we use the OCXO's output directly to counter , trigger the capture register with the "properly prescalled" unknown signal.

"Properly prescalled" is the unknown signal divided with a known integer divider, to give a period around a second or 10 sec as the example. (not mandatory, need further study to choose a most proper "coarse" period.).

Then the frequency will be Freq= F_OCXO/pulses_counted * divider. We observe that again the resolution is 1 LSB of the counter but now the resolution is 100 nanoseconds. (reciprocal method)

In general if F_unknown > F_timebase we use the first method and if F_unknown < F_timebase, the reciprocal method, to have max granularity.

And as you mention above, there are much more methods to increase resolution than to increase the gate period.

Precision depends on the time interval, increase it, get higher precision while waiting longer.

Hz = edges per second = clocks per timeinterval.

Thanks for the math fix.