Skip to main content
Braj Nandan Singh Jadon
Associate
March 9, 2018
Solved

How to handle a same external interrupt occurred from different sources in cortex-M4

  • March 9, 2018
  • 3 replies
  • 1541 views
Posted on March 09, 2018 at 06:39

Hello,

I am working on STM32f429ii controller, I want to used a interrupt from different sources say EXTI2, this interrupt can be activated for PH2 and PB2 so I was thinking to use this like,

void EXTI2_IRQHandler(void)

 

{

          if( !HAL_GPIO_ReadPin(GPIOH, GPIO_PIN_2)){                         //  Low level triggered interrupt

 

                           // if interrupt from this pin Do something

          }

          elseif( !HAL_GPIO_ReadPin( GPIOB, GPIO_PIN_2)){

                          //   if interrupt from this pin DO someting                          //its from keyboard so it can wait

           }

}

My question is can we use more then one pin for same interrupt, if yes then my code will work. if not what then what should I do. I don't have any free pins.

I can't use a timer interrupt as it may destroy other critical tasks and main already have other time consuming stuff.

#external-interrupt #interrupt-issue
This topic has been closed for replies.
Best answer by Tilen MAJERLE
Posted on March 09, 2018 at 07:28

Hello

singhjadon541

‌,

you cannot enable the same interrupt. In SYSCFG registers, you have to specify PORT and only single one can be entered. This means that active GPIO port will be the one you initialized last.

Best regards,

Tilen

3 replies

Tesla DeLorean
Guru
March 9, 2018
Posted on March 09, 2018 at 06:55

You can use only one pin per input, EXTI2 from either PA2, PB2, PC2, etc

With the higher order EXTI the pins are grouped, so EXTI 5 to 9 go to a single interrupt handler, so one could look for PA5,PA6,PA7,PA8,PA9, each should be flagged separately, but drop into EXTI9_5_IRQHandler

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Braj Nandan Singh Jadon
Associate
March 9, 2018
Posted on March 09, 2018 at 07:05

Hi, there

Thanks for clarifying. what will exactly happen if I enable same interrupt for different sources and what should I do, if you have any suggestions.

Tilen MAJERLE
Tilen MAJERLEBest answer
ST Employee
March 9, 2018
Posted on March 09, 2018 at 07:28

Hello

singhjadon541

‌,

you cannot enable the same interrupt. In SYSCFG registers, you have to specify PORT and only single one can be entered. This means that active GPIO port will be the one you initialized last.

Best regards,

Tilen