Skip to main content
TB_it
Associate III
Feb 9, 2020 3:50 PM UTC
Solved

Most STM32 timers have four (or more) channels. A quadrature encoder requires two channels. Is it possible to use a single timer on an STM32 for TWO quad encoder counters? If not, can the other channels be used to generate PWMs for driving H-bridges?

I’m particularly interested in using a single STM32G4 for two 32 bit encoder counters, if that is possible?

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
Feb 9, 2020 4:21 PM UTC

No. Look at Figure 266 in STM32G4 Series RM0440 Reference manual. Only the first two timer channels are connected to the encoder interface (tim_ti1fp1, tim_ti2fp2).

and "Encoder interface mode acts simply as an external clock with direction selection. This means that the counter just counts continuously between 0 and the auto-reload value in the TIMx_ARR register (0 to ARR or ARR down to 0 depending on the direction)." . So, you cannot use the other channels for PWM.

3 replies

KnarfB
KnarfBBest answer
Super User
Feb 9, 2020 4:21 PM UTC

No. Look at Figure 266 in STM32G4 Series RM0440 Reference manual. Only the first two timer channels are connected to the encoder interface (tim_ti1fp1, tim_ti2fp2).

and "Encoder interface mode acts simply as an external clock with direction selection. This means that the counter just counts continuously between 0 and the auto-reload value in the TIMx_ARR register (0 to ARR or ARR down to 0 depending on the direction)." . So, you cannot use the other channels for PWM.

Tesla DeLorean
Guru
Feb 9, 2020 4:25 PM UTC

TIM might have four channels, but only has ONE counter. So one TIM per encoder, Ch3/Ch4 not usable

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TB_it
TB_itAuthor
Associate III
Feb 22, 2020 1:16 AM UTC

got it, thanks. STMcube didn't exactly make this matter clear (the maintainer of STMcube might want to adjust that...)