IT lexicon › Hardware › DWT (Data Watchpoint and Trace)

DWT (Data Watchpoint and Trace)

Hardware På svenska → Updated: 2026-11-03

The Cortex-M unit that halts the processor when anyone touches a given address — and happens to contain the embedded world's favourite stopwatch.

DWT has a handful of comparators, usually four, that a debugger can aim at an address. When the core writes there it stops, and you see exactly which line trampled the buffer. This is the hardware behind a GDB watchpoint, and unlike the software fallback that single-steps every instruction, it costs no speed at all.

The most popular register is nonetheless CYCCNT, a 32-bit counter that ticks every clock cycle. Enable it through DEMCR and DWT_CTRL, read it before and after, and the difference is execution time to the cycle. At 168 MHz it wraps after a little over 25 seconds. Cortex-M0 and M0+ lack the counter, which people tend to discover while porting.

← Back to the lexicon