cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R5 Quadrature Encoder Hardware Connection

CYeow.1
Associate II

I'm trying to connect a quadrature encoder to my board using STM32L4R5. From what I understand, I should connect the A and B to TIM2, TIM3, TIM4 or TIM5.

  1. If I have 2 encoders, can I connect all 4 A and B signals from both encoders to the same TIM? Like TIM2_CH1, TIM_CH2, TIM_CH3 and TIM_CH4? Or I need to connect 2 different encoders to 2 different TIM?
  2. Where should I connect my Index signal from my encoder to? Is it the TIMx_ETR pin? From what I read on the forum, most of the posts said to connect to EXTI? Is ETR the same as EXTI? And on the EXTI section, it seems like PA0, PB0, PC0...PI0, are connected to the same EXTI0, do I need to connect my Index signal to different set of PAx like PA0 and PA1 for my interrupt to work or I can connect all the Index signal to the same set of Px0 like PA0 and PB0?

Thank you.

2 REPLIES 2
TDK
Guru

Separate encoders need to be on separate timers.

The encoder doesn't have hardware support for an index channel, you'll need to connect it to a GPIO pin as an external interrupt and program the appropriate logic within there (e.g. set timer index to 0 on first occurrence, or similar). Doesn't matter which pin you use for this. ETR and EXTI are different.

If you feel a post has answered your question, please click "Accept as Solution".

If the index signal is entirely placed between two consecutive edges (i.e. there's no edge occurring during the duration of index pulse), you could connect it to TIMx_ETR and use the slave-mode controller to automatically reset the counter upon that pulse.

But I don't think you would want to do that.

---

Individual EXTI pins have to be of different "number", e.g. PA0 and PB0 can't both be EXTI source.

JW