Question
2 different rotary encoder on STM32F103
Posted on May 18, 2018 at 07:29
Hello everyone,
I want to run 2 rotarty encoders on my STM32F I'm using cubemx.
The first one is a 2000 step rotarty encoder like these:
I use TIM4:
And everything works perfectly
and here is my code:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ if (htim->Instance==TIM4) //check if the interrupt comes from TIM4 { if (!(TIM4->CR1 & TIM_CR1_DIR)) MULT1K++; else MULT1K--; } if (htim->Instance==TIM3) //check if the interrupt comes from TIM4 { if (!(TIM3->CR1 & TIM_CR1_DIR)) pas = pas +5; else pas = pas -5; } }But on TIM3 I use a different encoder type:
http://www.mpja.com/Rotary-Encoder-with-Pushbutton-Switch/productinfo/30403+SW/
It has only 3 pins
I wired up like this:
except i didn't used PB6 and PB5
and here is my setup:
Any idea why it's not working?
Thank you very much for your help
stm32f103-timer rotary-encoder