On a Cortex-M microcontroller, an interrupt lets an external peripheral request processor attention. Its handler runs when the processor accepts the event, temporarily preempting the interrupted program. section 4.5.1 section 1.4.4
Cortex-M distinguishes two kinds of events handled through a shared mechanism:
- Exceptions originate inside the processor and include Reset, NMI, HardFault, and SysTick. section 4.5.1
- Interrupts generally originate in peripherals such as timers, GPIOs, or communication modules, which signal events such as timer expiry or data arrival. section 4.5.1
The vector table associates each event with a handler. The NVIC manages prioritization, preemption, and dispatch. On entry, the processor saves context on the active stack and transfers control to the handler; on return, it restores context and resumes the interrupted program. section 4.5.1 section 1.4.4
Figure 4.6 Transitioning in and out of a handler
Shows the processor transitioning from normal execution into a handler and back. section 4.5.1
Interrupt handlers and main code can access shared state at unpredictable times, creating a concurrency problem. Make sharing explicit: a short critical section that disables interrupts can control access, while frameworks such as RTIC or Embassy encode coordination rules through their APIs. Choose a mechanism that prevents uncontrolled access to shared data. section 1.4.4 section 4.5





