Posted on July 26, 2017 at 11:24Hello!
The encoders use TIM1, TIM2, TIM3, TIM4, TIM5 timers to work.
Every timer is separate inialised as encoder.
So when you want to use each one encoder , must call the same function ofcourse with the appropriate previously initialised TIM_HandleTypeDef as parameter!
TIM_HandleTypeDef htim1, htim2...;// at global scope
//inside your funtion (main or other)
TIM_Encoder_InitTypeDef
enci;//
//fill the structures wiith proper data
htim1.Instance = TIM1;
.....
enci.EncoderMode = TIM_ENCODERMODE_TI1;
.......
HAL_TIM_Encoder_Init(&htim1, &enci);//initialisation..
htim2.Instance = TIM2;
...
enci.EncoderMode = TIM_ENCODERMODE_TI1;
....
HAL_TIM_Encoder_Init(&htim2, &enci);//initialisation..
//after initialisation , start all encoders
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_1) ;//start each encoder
HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_1) ;
....