AnsweredAssumed Answered

stm32f429 rotary encoder external interrupt

Question asked by eb3484 on Jan 5, 2017
Latest reply on Apr 22, 2017 by Andrei Chichak

Hi,

I am using rotary encoder with two input i/o and i want to read the encoder pinA and pinB values with external interrupt. I am using callback function for two input PA0 and PA1. My functions are below:

 

In stm32f4xx_it.c:

void EXTI0_IRQHandler(void)
{
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); 
}

 

void EXTI1_IRQHandler(void)
{  
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
}

 

and in main.c:

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{

       if(GPIO_Pin == GPIO_PIN_0)

         {   

            //do something

          }

 

       if(GPIO_Pin == GPIO_PIN_1)

         {   

            //do something

          }

}

 

When i turn the encoder it does not works clearly, and when i debug the code, the call back function is called more than once. How can i fix it? Any adivse...

Outcomes