Are you aware of the most powerful weapon in your debug arsenal?

Posted by Magnus Unemyr on Aug 1, 2016 11:28:12 AM

Most ARM Cortex-M devices include a debug technology called Serial Wire Viewer, or SWV. This technology enables very advanced and super-useful debug capabilities at low additional hardware cost (in the microcontroller itself). In fact, you probably already have it.

However, many embedded developers are unaware SWV exist, or don’t know how to use it. If you are a Cortex-M developer, and don’t yet use the SWV capabilities in your debugging, you really ought to read this blog post!


To help highlight what you can do with SWV, I wrote a number of blog posts on this topic last year. Since those blog posts are equally relevant today, I take this opportunity to sum up those posts and provide links to them. Cortex-M developers who don't already use SWV for debugging might get a significant bump in debug efficiency.

Introduction to Serial Wire Viewer (SWV) event- and data tracing

This blog post provides an introduction to SWV and its related technologies SWD, SWO and ITM. You might want to read this first, before moving on to more capability- and problem-solving oriented posts.


Performance optimization using SWV statistical profiling

Using SWV, you can do performance optimization (also known as profiling) – and get detailed insights into the execution time behavior of all the functions in the system. This can help remove bottlenecks.


Measure execution time using SWV/ITM

You can use SWV and its related ITM technology to measure the execution time of some set of code; not only the time it takes for a function to execute, but any arbitrary section of code, within or across functions, on any granularity level.


Memory access history trace log using SWV/SWO

With the memory access history log, you can easily see all reads or writes that have been done to or from a variable or memory location, and for example find out what code line wrote a seemingly random erroneous value into some variable.


Real-time variable watch using SWV/SWO

Using real-time variable watch, you can monitor the values of certain variables live, without any need to stop execution on a breakpoint to query the value of a variable.


Software tracing using SWV/ITM

With ITM, you can instrument your code and get a real-time trace of your software behavior, on low- or high abstraction level. This application-level software tracing works live in real-time as your code execute at full speed.


printf() redirection to a debugger console using SWV/ITM (part 1 & 2)

Learn how to easily redirect printf() output to a debugger console – this is a very convenient way to get output from your target system without hooking up USB, UART or Ethernet/Telnet interfaces and PC client software. The basic functionality uses a single-channel setup:

For more advanced use-case scenarios; this technology also supports multi-channel configurations as outlined in this blog post.



Most Cortex-M cores include the SWV debug technology as part of its silicon implementation; and thus most of the ARM developers of today already have hardware support for it. Many really hard-to-find bugs can easily be spotted using the various debug capabilities offered by SWV, and Cortex-M developers ought to look into these features as it can significantly make work easier.

To learn more on SWV and related debugging capabilities, read this whitepaper:

Read our SWV event and data tracing whitepaper!



Topics: Debugging, Atollic TrueSTUDIO