cancel
Showing results for 
Search instead for 
Did you mean: 

Generate external interrupt from software and distinguish which pin the external interrupt is associated with?

arnold_w
Senior

I am writing code for the STM32F407G-DISC1 and STM32F760I-EVAL boards. I need to generate external interrupts in software and I need to be able to distinguish which pin (0, 1, 2, ... 15) each software generated interrupt is associated with. I understand that generating interrupts is done using NVIC->STIR, but this does not set any EXTI->PR bit so I can't tell which pin the interrupt is associated with. How can I achieve this? Is it possible to make the microcontroller assert the corresponding EXTI->PR bit, in addition to generating an interrupt in NVIC, somehow through software?

3 REPLIES 3
Pavel A.
Evangelist III

>  which pin (0, 1, 2, ... 15) 

The pins are named PA 0-15, PB 0-15 and so on. STM32 has several GPIO ports.

>  I understand that generating interrupts is done using NVIC->STIR, but this does not set any EXTI->PR

EXTI itself can generate software interrupts too, look at the EXTI_SWIER register. This should set bits in EXTI_PR. To see how EXTI entries are associated with GPIO pins, look at SYSCFG_EXTICRn registers.

-- pa

T J
Lead

if you can declare this function;

HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

it will interrupt you with the EXTI#

arnold_w
Senior

Thank you, EXTI_SWIER solved my problem perfectly.