cancel
Showing results for 
Search instead for 
Did you mean: 

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?

TB
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

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.

View solution in original post

3 REPLIES 3
KnarfB
Principal III

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.

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
Up vote any posts that you find helpful, it shows what's working..
TB
Associate III

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