Embedded systems

Interrupt

An interrupt is a hardware signal that yanks the processor away from whatever it's doing to handle something urgent right now, then returns it to exactly where it left off. Picture yourself reading a book when the doorbell rings: you mark your page, get up to answer the door, deal with the visitor, then come back and resume the very sentence you paused on. The doorbell is the interrupt; answering it is the interrupt service routine (ISR); the bookmark is the saved processor state. Without interrupts, you'd have to stop reading every few seconds to walk over and check whether anyone is at the door — wasteful and slow.

Interrupts are how embedded systems stay responsive without burning the CPU on constant polling. A pin changing, a timer overflowing, a byte arriving on the UART, an ADC finishing — each can raise an interrupt that pauses the main program, jumps to a short handler, and resumes. Good ISRs are tiny and fast (set a flag, copy a byte) and avoid slow work, because while one interrupt is being serviced others may be blocked. Priorities decide who wins when several fire at once, and you can mask (temporarily disable) interrupts to protect a few instructions that must not be cut in half.

Polling vs interrupts is a core design choice. Polling (repeatedly checking 'is it ready yet?') is simple but wastes cycles and adds latency; interrupts cost more complexity but let the CPU sleep until something actually happens — vital for low-power, battery-run devices.

Also called
IRQinterrupt request中斷請求