Home / Learn Embedded C / Interrupt-Driven UART Reception
Interrupt-Driven UART Reception
Combining UART receive interrupts with a buffer so no incoming byte is ever missed.
Theory in plain words
The basic idea
Interrupt-driven UART reception uses a receive interrupt (from the Interrupts group) to immediately capture each incoming byte into a buffer, decoupling "when a byte arrives" from "when the main loop gets around to processing it".
Why this comes up
A device receiving a continuous or bursty stream of data (sensor telemetry, a chat-style serial console) cannot reliably keep up using polling alone — interrupt-driven reception with a buffer is the standard, robust approach.
The mechanics
The ISR itself stays minimal (per the "keep ISRs short" lesson): read the byte, store it into a buffer, and return — all actual parsing/processing of the buffered data happens later in the main loop.
Where it is used
- Continuous data stream reception
- Serial console/chat interfaces
- Reliable multi-byte message handling
Try it
The ISR never waits for the main loop; it just stashes bytes and returns immediately, exactly the decoupling this lesson describes.
Try it: the main loop draining the buffer later, in a batch
All 3 bytes arrived while main() was doing something else, yet none were lost -- they are simply processed together once main() gets around to it.
Quick check
1. What problem does adding a buffer to interrupt-driven UART reception solve?
Buffering lets the ISR quickly stash each incoming byte, so the main loop can process them whenever it gets a chance, without any being lost while it is busy.