2020-05-20 12:22 AM
Hello,
I'm developing a custom board based on STM32F072B-DISCOVERY board.
I have an external PWM source with variable frequency (from 200Hz to 10Khz), i need to count how many pulses it generates.
How can it be done?
PS. I've tried with Imput Compare Timer but it's not suitable for my purpose because the frequency may change many times...
Thank you all.
Andrea
2020-05-20 12:26 AM
Set the timer to one of the External Clock modes, see TIM chapter in RM, description of TIMx_SMCR register.
JW
2020-05-20 12:33 AM
You can use the external clock mode (either ECM 1 or ECM 2) of the timers for this. Read the Time-base unit and Clock sources sections under the timer functional description in the reference manual.
The first two timer examples in Appendix A of the reference manual demonstrate both external clock modes.