Skip to main content
Graduate
September 13, 2025
Solved

Can the same timer with different channels be used to generate PWM and capture input on STM32G474VE?

  • September 13, 2025
  • 2 replies
  • 792 views

I am using the Advanced and General purpose timers on the STM32G474VE for PWM generation and Input capture.

Is it possible, for example, to use TIM4 Ch1 to generate PWM output and TIM4 Ch2 to be used as Input Capture simultaneously?
If these 2 features are used on different channels of the same timer are there any timing issues that could prevent me from using them simultaneously to drive, for example, a PWM controlled fan with a Tachometer that generates signals for the MCU?

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    Well the limitation here is there is ONE counter and it is bounded by the Period, ie ARR

    The CCRx registers latch or compare against the count, ie CNT

    If you are just modulating the Duty, you might be able to capture on another channel.

    I'd recommend using another TIM.

    2 replies

    Sud_09Author
    Graduate
    September 13, 2025

    Edit: I read this thread - https://community.st.com/t5/stm32-mcus-products/pwm-input-capture-and-pwm-output-with-same-timer/td-p/483410 

    But it talks about 'input PWM' NOT 'input capture'

    Graduate II
    September 13, 2025

    Input PWM combines two channels, from one input, and a reset so it can capture a period in one channel and duty in the other.

    Regular Input Capture just uses the channel input to latch the current count value and that wraps within the period.

    I'd generally use maximal count TIM to measure durations, otherwise there's a lot of fighting with the wrapping. 

    Graduate II
    September 13, 2025

    Well the limitation here is there is ONE counter and it is bounded by the Period, ie ARR

    The CCRx registers latch or compare against the count, ie CNT

    If you are just modulating the Duty, you might be able to capture on another channel.

    I'd recommend using another TIM.

    Sud_09Author
    Graduate
    September 13, 2025

    Makes sense. Thank you.