Home / Learn Embedded C / Input Capture Explained
Input Capture Explained
A timer feature that records the exact timer value at the moment an external signal edge occurs.
Breaking it down
Definition
Input capture is a timer peripheral feature that automatically records the timer's current count the instant a configured external pin sees a rising or falling edge — with no CPU involvement at the exact moment of the edge.
Why you need this
Measuring the precise time between two signal edges (a pulse width, a period, a frequency) needs exact edge timestamps — input capture gets these without the imprecision and latency of software polling or even an ISR's entry delay.
How it works
Because the hardware itself latches the timer value at the edge, the measurement is far more precise than having an ISR read the timer after being triggered — ISR entry latency would add timing error otherwise.
Where you'll see this
- Pulse width measurement
- Frequency/period measurement
- Precise external-event timestamping
Try it
The gap here represents the interrupt-latency error that hardware input capture avoids entirely.
Try it: measuring a period from two consecutive rising-edge captures
Two captures on the SAME edge type (both rising, or both falling), one period apart, give the signal's period instead of a pulse width.
Test what you just read
1. Why is hardware input capture more precise than reading the timer from inside an ISR triggered by the same edge?
An ISR only starts running some cycles after the edge (interrupt latency); input capture hardware records the timer value at the exact edge instant, before any software runs.