cancel
Showing results for 
Search instead for 
Did you mean: 

How can I count external PWM pulses with STM32F072?

AComa.170
Associate II

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

2 REPLIES 2

Set the timer to one of the External Clock modes, see TIM chapter in RM, description of TIMx_SMCR register.

JW

berendi
Principal

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.