liveBook · Manning

Interrupt

As explained in Embedded Software with Rust

An interrupt is a hardware or software event that requests processor attention and can trigger execution of an associated handler.

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
CH04 F06 Cabanis

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

How Embedded Software with Rust covers it

How deep it goes
Distinguishes exceptions from interrupts and traces vector dispatch and context preservation, while deferring detailed sharing APIs.
Examples
Uses timer expiry, data arrival, GPIO, and communication peripherals to illustrate interrupt sources and events.
What it assumes
Builds on embedded Rust project and build-system fundamentals, with sharing patterns following ownership fundamentals.
What you can do after
Understand how Cortex-M dispatches handlers and why interrupt-shared state needs controlled access.
How it connects
Connects interrupts to exceptions, vector tables, the NVIC, critical sections, and concurrency.

Also explained in

Compare how 6 books explain interrupt →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.