EECS 373 - Fall 2026 - Lecture 6: “Interrupts”
Overview
The lecture explains how ARM Cortex-M interrupts let a processor respond to asynchronous events without continuously polling peripherals, then traces the path from a peripheral IRQ signal through the Nested Vectored Interrupt Controller (NVIC) and vector table to an interrupt service routine (ISR). It also covers exception stacking and unstacking, the register state that must be preserved for ABI compliance, and why ISRs should stay short; the course device is described as supporting about 96 interrupts, while the NVIC can handle up to 256.
Key takeaways
- Polling a GPIO button trades processor availability for response time: a tight loop can react in about three cycles, but adding work between checks increases latency.
- A peripheral interrupt reaches the Cortex-M core over a dedicated IRQ line, not through a bus transaction; the NVIC maps that signal to a handler.
- The vector table begins with the initial stack pointer and reset handler, and ARM-defined system exceptions mean external IRQ vector positions use an offset of 16.
- Cortex-M exception entry automatically saves R0-R3, R12, LR, PC, and PSR; an ISR must separately preserve R4-R11 if it modifies them.
- A special exception-return value in LR causes automatic unstacking, restoring the interrupted context and returning execution to the main program.
- Short ISRs reduce disruption to the main program; copying data or setting a flag is often preferable to doing extensive processing inside the handler.
Chapters
- The instructor says interrupt implementation details are unlikely to be tested, though a conceptual exam question is reasonable.
- Students should attend the staffed lab, which is not due this week because of the exam; the next class includes a full exam review.
- A servo combines a DC motor with feedback hardware, described as a comparator that helps move it to a requested position.
- The signal wire carries a pulse train whose pulse width maps to an angle; common ranges include plus or minus 90 degrees and plus or minus 180 degrees.
- Servo range, weight, and torque vary by model; an example uses an IMU and controller to make a servo mimic motion.
- The exam provides datasheets for a fictional processor, microphone, and LCD, so students can focus on interpreting specifications rather than memorizing every instruction.
- The processor datasheet includes architecture, pin assignments, and registers; students should infer how peripherals are built and operate from these details.
- The instructor recommends reviewing the datasheets and practice exams, then raising errors or questions through Piazza and office hours.
- Polling repeatedly reads a GPIO input register to detect events such as a button press, consuming processor time even when nothing has changed.
- A tight button-polling loop can respond in about three cycles, but doing other work between checks increases response latency.
- Interrupts address the responsiveness trade-off by notifying the processor when an event occurs, rather than requiring continuous checks.
- An interrupt service routine (ISR) handles an event, then execution returns to the interrupted program as though its state had been preserved.
- Interrupt sources include peripherals and timers, as well as core exceptions such as divide-by-zero faults and supervisor calls.
- The lecture frames an interrupt as a hardware-triggered transfer of control that must preserve enough processor state to resume the original code.
- Peripherals cannot initiate bus transactions, so each interrupt source instead has a dedicated IRQ signal line to the core’s interrupt controller.
- The NVIC interprets the IRQ line and determines which exception or handler should run; the signal itself is only a bit indicating that an event occurred.
- A GPIO interrupt requires datasheet-supported hardware and configuration, such as enabling an interrupt and selecting a positive- or negative-edge trigger.
- The vector table is an address table in memory: its first word initializes the stack pointer, and the reset handler address follows it.
- On startup, the reset handler performs processor-specific boot work before execution reaches main; code may be copied from flash to SRAM.
- ARM-defined system exceptions occupy reserved vector positions, while external IRQ numbers are offset by 16 when mapped into the vector table.
- The interrupted program must resume with its registers and condition state intact, including the program counter and program status register (PSR).
- The Cortex-M exception mechanism automatically preserves R0-R3, R12, LR, PC, and PSR; the stack pointer returns to its prior position after unstacking.
- R4-R11 are not part of that automatic save set, so an ISR that uses them must preserve them according to the ABI.
- When an interrupt is accepted, the processor automatically pushes the basic exception frame, including R0-R3, R12, LR, PC, and PSR, onto the stack.
- The processor then enters the selected handler and sets a special LR return value that signals exception return.
- Returning through that special value triggers automatic unstacking, restoring the saved registers and the interrupted program’s state.
- A SysTick interrupt example shows the NVIC selecting the handler address, stacking state, and setting the PC to the ISR.
- The ISR may use automatically saved scratch registers such as R3, but it must save a callee-saved register such as R4 before modifying it.
- A normal branch to the special exception-return address causes unstacking; modifying R4 without preserving it leaves the main program corrupted.
- Polling becomes less responsive as the main program does more work, while an interrupt lets the processor handle events asynchronously.
- The course device is described as having about 96 interrupt sources, compared with an NVIC capacity of up to 256.
- ISRs should generally do a small task, such as copying data or setting a flag for main to process; the next lecture will cover priorities and nested interrupts.
Transcript excerpt
0:02 All right, we can begin. Let's see here. All right, sorry for technical delays. We're just getting slides downloaded. So, today we're going to be talking about interrupts. Um we'll go actually go through the uh the data sheet as well. But, homework is due today. There's office hours after class. And then uh next week or next on Wednesday we'll talk through logistics of the exam. We'll talk about that a little bit today, but uh I'll also go through the data sheet. So, before we get started, are there any questions? Yeah. >> How many lectures uh are there that are going to be covered on the exam? >> How many lectures? >> Yes. I figured what lectures is the content coming from? >> Um we'll talk So, we're not going to be
0:50 able to get into deep into um interrupts, and you won't have a lab on interrupts. So, I would say the nitty-gritty of getting into interrupts is probably not going to be on the exam, but maybe a conceptual question would probably be really reasonable after today's lecture. And we'll do Wednesday we'll do a full review of what's going to be on the exam. Give you guys a chance to ask questions. What other questions you have? Yeah. >> Do we need labs? >> Yes, you have lab this week. Go to lab. So, we're not going to make the labs due this week. It's a little bit longer lab, but it also takes your pressure off, right? So, you should go to lab. They're going to be staffed. They're going to be giving you the presentations on how to do the lab, but because we have an exam this week, we're not making labs due this week. So, it kind of takes some of
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Interactive Sensing and Computing Lab.