Skip to main content
TB_it
Associate III
February 9, 2020
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?

  • February 9, 2020
  • 3 replies
  • 1226 views

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.
Best answer by KnarfB

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
KnarfBAnswer
Super User
February 9, 2020

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
February 9, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
TB_it
TB_itAuthor
Associate III
February 22, 2020

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