Debugging, Logging, and Monitoring via SWO Trace (STM32 ITM & DWT) - Phil's Lab #173

Phil’s Lab
Phil’s LabMay 4, 2026

Why It Matters

SWO‑based debugging provides high‑resolution logging without extra hardware, streamlining development and cutting costs for embedded system designers.

Key Takeaways

  • SWO uses a single pin for printf‑style debugging.
  • ITM ports multiplex up to 32 data streams over SWO.
  • No UART/USB needed, freeing pins for other peripherals.
  • STM32CubeIDE configures core clock for accurate SWO timing.
  • Debug probes like ST‑Link and J‑Link support SWO out‑of‑the‑box.

Summary

The video demonstrates how Serial Wire Output (SWO), together with the Instrumentation Trace Macrocell (ITM) and Data Watchpoint and Trace (DWT), can replace traditional UART or USB logging on ARM Cortex‑M microcontrollers, using an STM32H7 on a custom QueenB radio‑control PCB.

Key insights include the ability to stream printf‑style messages and live variable data over a single dedicated trace pin, the multiplexing of up to 32 ITM stimulus ports onto that pin, and the necessity of configuring the core clock correctly in STM32CubeIDE to match the SWO output rate.

The presenter remaps the standard write function to ITM_SendChar, routes ADC readings from thumb‑stick potentiometers through ITM ports, and validates the setup with an ST‑Link V2/V3 or Segger J‑Link debugger. He highlights a 480 MHz core clock, DMA‑driven ADC sampling, and the use of the Serial Wire Viewer to visualize the data.

By eliminating separate UART/USB peripherals, developers free valuable pins, reduce board complexity, and accelerate firmware debugging cycles—benefits that translate into faster time‑to‑market and lower BOM costs for embedded products.

Original Description

Printf, variable monitoring, debugging, and more using the serial wire trace output (SWO).
Limited-time: $2 for 6-layer PCBs up to 100×100 mm - grab your $33 coupon now: https://jlcpcb.com/events/6-layer-pcb?from=PhilsLab (Ad)
Altium Develop: http://altium.com/yt/philslab (Ad)
[SUPPORT]
[LINKS]
[TIMESTAMPS]
00:00 Intro
01:46 JLCPCB (Ad)
03:21 Altium Develop (Ad)
04:26 SWO & HW Overview
07:31 CubeIDE Set-Up
09:03 ITM Port & SendChar
12:12 printf via ITM
13:14 Enabling SWV
16:04 Multiple ITM Ports
18:34 DWT Comparator Variable Monitor
22:44 Outro

Comments

Want to join the conversation?

Loading comments...