The remaining 11 pins on each GPIO peripheral get grouped into the remaining two interrupts. What this means is that on the F1 through F7 families, GPIO pins 0 through 4 get a dedicated interrupt which they share with other GPIO peripherals. The lines themselves are connected using muxes to GPIO pins as in the following diagram: STM32F4 EXTI to GPIO peripheral mapping. For the first group, these are described as:Īs one can see, we get 16 lines on the EXTI peripheral which can be used with GPIO pins, but some of those lines are grouped together, requiring a bit more work in the interrupt handler to determine which line got triggered if desirable. On the STM32F1, F4, and F7 STM32 families, the EXTI peripheral has 7 interrupts associated with it, and 3 on the F0 (STM32F04x and others). The same is true for the EXTI (EXTernal Interrupt/event controller) peripheral. EXTI peripheral block diagram (RM0090, 12.2.5). Just about any peripheral - whether it’s a timer, USART, DMA channel, SPI, or I2C bus - has at least one interrupt related to them. faults), while the ones which are usually most interesting to a developer are those related to non-core peripherals. Some of these interrupts are reserved for processor, memory or data bus events (e.g. RM0090, Table 62), which has over 90 entries. These interrupt channels all have a specific purpose, as defined in the vector table (e.g.
If we look at the reference manual for the STM32F4xx MCUs (specifically RM0090, section 12), we can see that for the NVIC interrupt lines, we get whittled down to 82 to 91 maskable interrupt channels from the up to 250 total for the NVIC core peripheral in the Cortex-M4. These interrupts are not all freely assignable, however. Depending on the exact Cortex-M core, this peripheral can support hundreds of interrupts, with multiple priority levels. Both types of interrupts use the same core peripheral in the Cortex-M core: the Nested Vectored Interrupt Controller, or NVIC. Interrupts on STM32 MCUs come in two flavors: internal and external. Some Assembly Required Diagram of the Cortex-M4 core in the STM32F4 family of MCUs. In this article we will take a look at what it takes to set up interrupt handlers on GPIO inputs, using a practical example involving a rotary incremental encoder. Beyond this, interrupts along with interrupt handlers provide for a convenient way to respond to both external and internal events. Especially in something like an industrial process or in a modern car, there are many events that simply cannot be processed whenever the processor gets around to polling a register. On microcontroller systems like the STM32, interrupts are even more important, as this is what allows an MCU to respond in hard real-time to an (external) event. While on desktop computers these interrupts are less prominent than back when we still had to manually set the IRQ for a new piece of hardware using toggle switches on an ISA card, IRQs along with DMA (direct memory access) transfers are still what makes a system appear zippy to a user if used properly. They’re also crucial for making computer systems work as well as they do, as they allow for a system to immediately respond to an event. Interruptions aren’t just a staple of our daily lives.