External interrupt and button debounce
Hi all,
I currently work on STM32F030K6 .
I am working with a reed switch connected to pin PA8 (EXTI8).
I havec onfigured the PIN like : "external Interrupt Mode rising/falling ....
I need to perform an action on the rising edge AND on the falling edge.
But since the switch is slow there are certainly bounces.
What would be the good method to not detect the bounces.
I tried to set a timer but it does not work. I tried to disable the interrupts but it does not work either.
I have create a test code like this.
while (1)
{
if (Bouton_WU == 1) // ILS
{
HAL_Delay(500);
Bouton_WU = 0;
Envoi_msg();
}
if (test > 5)
{
test = 0;
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
switch (GPIO_Pin)
{
case ILS_Pin: Bouton_WU = 1;
test++;
break;
}
}
I tried to use the function : "HAL_NVIC_DisableIRQ(EXTI4_15_IRQn);" in several places in the code without succes.
I tried to put some HAL_delays without succes.
I used the debugger to watch the value of my variable "test", and the value is higher 10 in every change of my switch.
do you have any idea to deal with the problem ?
thanks for reading me
