Skip to main content
arnold_w
Senior II
August 19, 2018
Question

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

  • August 19, 2018
  • 3 replies
  • 1188 views

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?

    This topic has been closed for replies.

    3 replies

    Pavel A.
    August 19, 2018

    >  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
    Senior III
    August 19, 2018

    if you can declare this function;

    HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

    it will interrupt you with the EXTI#

    arnold_w
    arnold_wAuthor
    Senior II
    August 20, 2018

    Thank you, EXTI_SWIER solved my problem perfectly.