Hi, I use QEI library to work with encoder. Everything works fine. But when try to create my own class like it’s shown below, it compiles fine but doesn’t work. What do I do wrong?
The sample does not compile because the Encoder’s constructor is private. I did not run a full test but the InterrupIn callbacks seem to be triggered. So after making the constructor public it should work.
Hi, Zoltan, thank you for your answer. I found another problem. At my project I use 4 different encoders, so I have to create 4 QEI objects. And it seems like there is a conflict between two of them:
The program doesn’t work if I initialize both of them, but according to the documentation those pins are connected to different timers: TIM3 and TIM4.
I use BlackBoard STM32F407VET6.
Also I noticed, that they probably share some common resources, because encoder that works is the last one I initialize. So the first encoder in the code always doesn’t work.
Do you know where can be the problem?
The number of interrupt-in channels (lines) is usually less than the number of GPIO pins. In order to have interrupt-in capability on each GPIO pin the pins are grouped and each group is connected to different interrupt-in channel (line). If it happens that you configure two on more pins as interrupt-in and they belong to the same group (it means that they are connected to the same interrupt-in channel (line)) then only the latest pin will work as interrupt-in. Check the datasheet of your MCU for grouping of GPIOs to interrupt-in channels. Most likely PA_6 and PB_6 are connected to the same interrupt-in channel (they belong to the same group) that’s why only PB_6 (configured for interrupt-in as last) works as interrupt-in.