Search code examples
interruptstm32f4discoverydebouncing

Debouncing on stm32f4 discovery


void EXTI3_IRQHandler(void){


    //Clear the EXTI pending bits   
    NVIC_ClearPendingIRQ(EXTI3_IRQn);
    EXTI->PR|=(1<<3);

    count++;    


}

This is a my interrupt routine. if press the button the intterrup occurs and the then count is incremented. I dint know how ı solve bounced button problem. Please help me!


Solution

  • This usually involve reading the input after a small delay.

    In your interrupt handler, clear the pending bit and set a flag to true.

    In your main loop, check if the flag is true. If it is, add a delay (20 ms for example), read your input and clear the flag.

    If the delay is not acceptable in your application, do the same with a timer.