Home / Learn Embedded C / JTAG and SWD Explained
JTAG and SWD Explained
The two most common hardware debug interfaces used to control and inspect a running microcontroller.
The idea, explained simply
What it is
JTAG and SWD (Serial Wire Debug) are hardware debug interfaces letting an external debugger probe control the chip directly: halting execution, single-stepping, reading/writing memory and registers, and setting breakpoints — all without any special debug code built into the application itself.
Why it matters
This is fundamentally different from printf-style debugging (covered next): the debugger can inspect and control the chip's actual internal state directly, even stopping execution completely, which is essential for diagnosing certain classes of bugs printf alone cannot reveal.
Mechanically speaking
SWD uses just 2 wires (compared to JTAG's 4-5), making it popular on many modern ARM Cortex-M chips specifically because it needs fewer dedicated debug pins, while JTAG remains common on many other architectures and for chaining multiple devices together.
Shows up in
- Hardware-level debugging
- Breakpoint-based bug diagnosis
- Register/memory inspection
Try it
A real debugger does this over the JTAG/SWD wires, directly, without the firmware itself needing any special debug code.
Try it: single-stepping through instructions
A debugger single-step advances exactly one machine instruction, whose size can vary, before halting again and letting you inspect state.
Check yourself
1. What capability do JTAG/SWD hardware debug interfaces provide that printf debugging cannot?
JTAG/SWD give direct, external control over the CPU's execution and internal state — something printf statements embedded in the running code cannot provide on their own.