Skip to main content
AComa.170
Associate II
May 20, 2020
Question

How can I count external PWM pulses with STM32F072?

  • May 20, 2020
  • 2 replies
  • 932 views

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

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
May 20, 2020

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

JW

berendi
Principal
May 20, 2020

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.