Skip to main content

Subsection 9.1.3 Why a Pin’s Interrupt Needs a Front End

Every source in the list above is a single peripheral, and each one gets its own line into the NVIC, the Nested Vectored Interrupt Controller that we introduced last week as the intermediary between every interrupt source and the CPU. One peripheral, one line, one entry in the vector table. This concept does not carry over to interrupts from GPIO pins, because there are so many of them: the STM32C031C6 has 45. Giving every pin its own NVIC line would mean dozens of extra lines and dozens of extra vector-table entries for a chip on which almost all of them would sit unused.
So the pins do not have a direct line each to the NVIC. Instead, they go first to a separate block called the EXTI, the Extended Interrupt and Event Controller, which is best thought of as a switchboard. It accepts far more inputs than it has outputs, it can be told which inputs to listen to, it can be told what to listen for (a rising edge, a falling edge, or both), and it condenses everything it hears onto a small number of lines into the NVIC. Configuring a pin interrupt therefore takes several settings, not one: you have to tell the switchboard which pin, which edge, and whether to pass the result on at all.
In class we’ll take this idea and explore the registers that we need to program in order to define the behavior we wish to see for our pin change interrupt. We’ll also look at the consequences of condensing many pins onto few lines.