2019-02-05 08:19 AM
I am using an STM32F303K8T and am trying to use a flow sensor with an output of 15 Hz - 225 Hz.
2019-02-05 08:33 AM
Depends on the granularity of the measurement you seek, so the prescaler on the TIM, the width of the counter, and input prescaler, where you can measure 1, 2, 4 or 8 periods.
The frequencies you describe are LOW. For HIGH frequencies one might look at External Count mode.
2019-02-05 09:39 AM
Thanks Clive. What is the point of measuring 1/2/4/8 periods?
2019-02-05 10:45 AM
Your frequency is very low.
Say your STM32 runs at 32 MHz.
Take a 16 bit timer and prescale by 128 and the timer clock will be 250kHz
The timer overflow period will be 250000 / 65536 = 3,8 Hz
Any frequency higher than this one and below 1 kHz should be accurately measured with input capture or pulse capture. you'll get period and duty cycle (high and low time). The accuracy will depend on the timer 32MHz clock frequency precision...
This is just a quick example.
Input signal prescale is typically for very high incoming signal frequency.
2019-02-06 02:39 PM
Which prescaler are you referring to (128)? I noticed on CubeMX there is an input capture prescaler division ratio and a prescaler PSC in counter settings.
2019-02-06 02:41 PM
Thanks Clive. What do you mean by measuring 1/2/4/8 periods? And what is the difference between the prescaler on the TIM and the input prescaler?