2019-02-18 09:58 AM
Timer 1 inittalization code is below:
TIM1_TimeBaseInit(10, TIM1_COUNTERMODE_CENTERALIGNED1, 1000, 1);
TIM1_ICInit(TIM1_CHANNEL_1,TIM1_ICPOLARITY_FALLING ,TIM1_ICSELECTION_DIRECTTI ,TIM1_ICPSC_DIV1,0);
TIM1_ICInit(TIM1_CHANNEL_2,TIM1_ICPOLARITY_FALLING ,TIM1_ICSELECTION_DIRECTTI ,TIM1_ICPSC_DIV1,0);
TIM1_EncoderInterfaceConfig(TIM1_ENCODERMODE_TI12,TIM1_ICPOLARITY_FALLING ,TIM1_ICPOLARITY_FALLING );
TIM1_Cmd(ENABLE);
I have the following in an infinite loop after the code above runs:
TIM1_GetCounter();
When i turn my encoder whether clockwise or anti clockwise TIM1_GetCounter() returns me one and goes back to zero.