Random interrupts when an external interrupt trigger occurs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-21 2:20 PM - edited 2025-04-21 2:23 PM
I'm generating external interrupts on an WeActStudio STM32F446RET6 board. I've the pins configured as pull-up. When I set one of them to GND, several random interrupts from other pins are generated. For example, if I connect pin PB3 to GND, I get interrupts from PB3 and PB4.
I attach the complete project, I'm compiling it with Visual Studio Code.
What could be the cause?
My callback function is:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
static uint32_t last_interrupt_time[6] = {0}; // For multiples pins
uint32_t current_time = HAL_GetTick();
#define debounce_time 50 //ms
switch(GPIO_Pin) {
case GPIO_PIN_0:
if (current_time - last_interrupt_time[0] > debounce_time) {
last_interrupt_time[0] = current_time;
printf("INT PB0\r\n");
}
break;
case GPIO_PIN_1:
if (current_time - last_interrupt_time[1] > debounce_time) {
last_interrupt_time[1] = current_time;
printf("INT PB1\r\n");
}
break;
case GPIO_PIN_3:
if (current_time - last_interrupt_time[2] > debounce_time) {
last_interrupt_time[2] = current_time;
printf("INT PB3\r\n");
}
break;
case GPIO_PIN_4:
if (current_time - last_interrupt_time[3] > debounce_time) {
last_interrupt_time[3] = current_time;
printf("INT PB4\r\n");
}
break;
case GPIO_PIN_5:
if (current_time - last_interrupt_time[4] > debounce_time) {
last_interrupt_time[4] = current_time;
printf("INT PB5\r\n");
}
break;
case GPIO_PIN_6:
if (current_time - last_interrupt_time[5] > debounce_time) {
last_interrupt_time[5] = current_time;
printf("INT PC6\r\n");
}
break;
default: break;
}
}
Solved! Go to Solution.
- Labels:
-
GPIO-EXTI
-
Interrupt
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-21 2:24 PM
Several EXTI dump into the same Handler?
HAL dispatchs in a shot-gun method rather than qualifying?
You've got noise or signal bounce on your inputs?
TIM pins in input capture might provide additional filter and clock options.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-21 2:24 PM
Several EXTI dump into the same Handler?
HAL dispatchs in a shot-gun method rather than qualifying?
You've got noise or signal bounce on your inputs?
TIM pins in input capture might provide additional filter and clock options.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-21 11:08 PM
Shared EXTI Handlers: Yes, I’m aware that EXTI9_5 shares one handler (for pins 5-9), but my issue also occurs with PB3 (EXTI3) and PB4 (EXTI4), which have dedicated handlers (EXTI3_IRQHandler/EXTI4_IRQHandler).
Noise/Bouncing: I already had software debounce implemented (50ms delay in callbacks), I've now added hardware debouncing (1kΩ series resistor + 100nF capacitor to GND) on a pin. It works! I didn't know that noise on a single pin can trigger interrupts on other pins.
