HAL library 04- EXTI for STM32Fxxx

EXTI library is used to set GPIO pin as external interrupt. It is designed to easily enable/disable interrupt and handle irq requests.

If you don’t know how EXTI works on STM32F4 or STM32F7 lines, you should take a look here.


Read more about new HAL libraries


  • Allows up to 16 external interrupts at a time
  • Allows to setup rising or falling edge for pin
  • Allows to disable interrupt
  • Single function for interrupt handling
  • Works for STM32F0, STM32F4 and STM32F7 series


  • HAL
  • TM
    • STM32Fxxx HAL
    • defines.h
    • GPIO

Library interrupt handling

STM32F4/7 has 7 interrupt handler function. They are all implemented in my library and all handlers calls one function, which is single callback function for different EXTI lines. On bottom example you will be able to see how to handle interrupts with single function.

For STM32F0, there are 3 interrupt handlers. They are also implemented in my library and all of them calls one function. Check example on the bottom.

Functions and enumerations


Project is available on my Github account, download all libraries below.

TM STM32 Libraries

STM32 libraries based on STM32Fxxx HAL drivers.


Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • Pingback: All STM32 HAL libraries - STM32F4 Discovery()

  • Daniel

    hello, how can I go back to the main after an interruption has occured? is that possible? or do i need to use another function??

    • It automatically goes back from where irq started.

      • Daniel

        ok, its true, thanks

  • alexander della vedova

    how to use this library with mbed or coide?

  • michael

    Hi, I’ve had a problem with this example (I’ve downloaded it from your Github project) when I try to compile, I got an error . I tried to solved by changing TM_DISCO_BUTTON_PORT and TM_DISCO_BUTTON_PIN for DISCO_BUTTON_PORT and DISCO_BUTTON_PIN in the main file and it works. Finally I like your website.

  • Oleksandr SN

    Hi. How I could check PORT of the PIN in TM_EXTI_Handler(uint16_t GPIO_Pin) ? I want to use EXTI on Pin8 from PORTA and PORTB.