STM32 Guide: Interrupts

Sanskar Biswal
Jan 4 · 2 min read
Image for post
Image for post
Fig.1 STM32 F4 Dev Kit


This is tutorial is not intended to be a guide for learning C language or about the STM32 platform. It’s primary target is to provide developers a concise guide about integrating peripheral modules and features into active applications.

If you are a beginner, I would recommend you look into an STM32 Project Setup guide like this one.


Interrupts in microcontroller are inputs for external sources or internal processes, which when triggered can stop the currently executing task and run a different sequence of tasks.

The applications range from making real-time response systems to reducing power consumption and it is used in a wide variety of embedded systems.

Interrupts are essentially signals and can arrive at the GPIO pin in one of the following 3 methods

  • Rising Edge
  • Falling Edge
  • Toggle (Rising and Falling)


STM32F4 has 7 interrupts

Fig.2 Table of EXTI Mapping

Setting Up Interrupt Handler

void EXTI0_IRQHandler(void) {
/* Make sure that interrupt flag is set */
if (EXTI_GetITStatus(EXTI_Line0) != RESET) {
/* Do your stuff when EXTI0 is changed */
/* Clear interrupt flag */
/* Handle IRQ10-15 interrupt */
void EXTI15_10_IRQHandler(void) {
/* Make sure that interrupt flag is set */
if (EXTI_GetITStatus(EXTI_Line12) != RESET) {
/* Do your stuff when EXTI is changed */

/* Clear interrupt flag */


In this tutorial, we discussed the methods for using External Interrupts (EXTI)


Vicara Hardware University

Taking the “Hard” out of Hardware

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store