SWO

From SEGGER Wiki
Jump to: navigation, search

SWO

When introducing the SWD interface, ARM also introduced an optional extension for SWD, called Serial Wire Output (SWO). SWO specifies a dedicated pin, in addition to the debug signals of the SWD interface, which allows the target CPU to output specific data like printf output on a dedicated pin via UART or Manchester protocol. This pin is unidirectional, so it is not possible to send data to the target CPU on this pin.

The Instrumentation Trace Macrocell (ITM) and Serial Wire Output (SWO) can be used to form a Serial Wire Viewer (SWV). The Serial Wire Viewer provides a low cost method of obtaining information from inside the MCU.

Note: Not all targets that support SWD also support SWO. Moreover, SWO is not supported by all CPU architectures that support SWD.

SWO clocking

The SWO pin is connected to the Trace Port Interface Unit (TPIU). This needs to be clocked so the SWO pin can output data. On most Cortex-M target devices this clock is derived 1/1 from the CPU core clock. Most SWO software tools that display the data stream will ask for an SWO or CPU clock in the configuration settings. Here the SWO clock needs to be entered that will be set after the system initialization is finished (usually this is the case at the point where you application jumps to main). As mentioned before in most cases this is simply the CPU core clock.

Troubleshooting

  • On some target devices however the SWO clock does not follow the CPU clock directly, but e.g. has an own static clock source or similar. To still be able to use SWO in such setup the debugger must know the "new" actual clock source. So either set the static clock source as the SWO clock speed in the configuration of the SWO software tool you are using, or you can use a JLinkScript for this with function SWO_GetSWOBaseClock.
  • Some target devices also offer multiple different pins that can be used for SWO or some additional initialization steps are required for the SWO pin to be active. In such cases the pin init must be done by the user. We recommend the usage of a J-Link script for this with script file function SWO_EnableTarget.