cancel
Showing results for 
Search instead for 
Did you mean: 

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

Sud_09
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4
Sud_09
Associate II

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'

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Makes sense. Thank you.

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. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..