cancel
Showing results for 
Search instead for 
Did you mean: 

Random interrupts when an external interrupt trigger occurs

juanj
Visitor

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;
  }
}

 

1 REPLY 1

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. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..