Skip to main content
Visitor II
October 7, 2024
Question

Single timer for encoder on Channel 1 & 2 and PWM generation on Channel 3?

  • October 7, 2024
  • 2 replies
  • 712 views

Hi. I'm using the STM32F407VE6 Microcontroller board. Is it possible to use a single timer to generate PWM from channel 3 and read the encoder values from channel1 & 2 of the same timer? 
When I tried using 2 different timers, one for PWM and the other for the encoder it worked fine.
 If it's impossible to use the same timer for both operations, why are channels 3 and 4 available for PWM generation?

    2 replies

    TDK
    Super User
    October 7, 2024

    Timers have a single counter register. You cannot use a timer for an encoder and for PWM at the same time.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    waclawek.jan
    Super User
    October 7, 2024

    > If it's impossible to use the same timer for both operations, why are channels 3 and 4 available for PWM generation?

    Even with the counter clocked from the encoder, you may find uses for the compare features, including the functionality which is called PWM. You may for example want generate a pulse when a rotary encoder rotates through some portion of its path.

    JW