Home / Learn Embedded C / Busy-Wait Delay vs Timer Delay
Busy-Wait Delay vs Timer Delay
Comparing the two common ways to make embedded code "wait", and when each is appropriate.
How to think about this
In plain terms
A busy-wait delay blocks the CPU in a counting loop doing nothing useful until time passes; a timer-based delay lets a hardware timer track the time while the CPU is free to do other work (or sleep) in the meantime.
Why we use it
Simple scripts and quick demos often use busy-wait for simplicity; real production firmware almost always prefers timer-based delays (or full event-driven designs) once more than one thing needs to happen "at the same time".
Under the hood
A busy-wait delay's accuracy depends on the compiler, optimization level and clock speed unless carefully calibrated; a hardware timer's accuracy depends only on the clock source feeding it, which is far more predictable.
Real-world use
- Delay implementation choice
- Responsiveness-critical code
- Power-sensitive designs
Try it
This course's DELAY_MS/DELAY_US calls are meant to represent the timer-delay model, even in examples that read like simple blocking calls.
Try it: a busy-wait loop that actually blocks other work from happening
Nothing else in the program can run while the CPU is stuck counting inside the busy-wait loop.
Quick quiz
1. Why do production embedded systems usually prefer timer-based delays over busy-wait loops?
A timer-based delay does not block the CPU from other work, and its timing is tied to a stable clock source rather than instruction-counting.