GPIO pushbutton debounce using HAL_NVIC_DisableIRQ, newbie question
Hi all, i have very simple gpio pushbutton debounce code, but 50% of the time it still gets a double-bounce (led toggles twice), i.e. the debounceCount is double incremented as the interrupt service routine is mysteriously called twice. How can this be if the interrupt is immediately disabled?. Is the switch bounce sometimes so quick that two presses are queued up before the interrupt is disabled?
Within main() , if the button is pressed, there is a while(1) if(butIsPressed) {butIsPressed=FALSE; HAL_Delay(1000); and then HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
HAL_NVIC_DisableIRQ(EXTI4_15_IRQn);
debounceCount++;
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3); // Toggle The Output (LED) Pin
butIsPressed = TRUE;
}
