2024-10-23 02:56 PM
Hey,
I want to read an EC11 encoder without disturbing the main loop, so I decided to use interrupts.
Can I connect both pin A and pin B of the encoder to PA1 and PB1, and use only EXTI1 to map the switching events to the same interrupt routine?
2024-10-23 02:59 PM
No
Interrupt on ONE, read the other for direction? If they work like standard Quadrature Encoders.
See if these go to usable TIM inputs? You can put a TIM in Input Capture, and get an interrupt from those events, on all four channels.
2024-10-23 04:37 PM
If you are using the pins in EXTI, then yes. You'll need to interrupt on both edges and keep track of the last state of each pin. When you get an interrupt, you'll need to read both pins and compare the current state to the last state.
The pin that has a different state would be the pin that caused the interrupt. Then you'll need to keep track of the on/off state to determine the direction. It's going to be more work than needed when you can easily use the Timer in encoder mode instead.
2024-10-23 05:20 PM
Hi,
There are a couple of EXTI's that share the same interrupt handler (eg EXTI5 & EXTI9, EXTI10 & EXTI15). If you can route the pins to them, that maybe helpful...
Kind regards
Pedro
2024-10-23 05:57 PM
I was looking for a post that asked a similar question. I think the question was how would you know which pin caused the interrupt since HAL Driver would return the same pin status. I believe i answered that question which i explained in the above post.
But then I started to remember that architecturally the STM32 can only interrupt on 1 pin using the same bit of a different port. So I was wrong. Actually the last pin to be configured for interrupt would take priority and cancel out the previous pin set for interrupt.