Cortex-Debug SWO Decoding and Graphing

Jan. 2, 2018

SWO Decoding and Graphing

NOTE: THIS DOCUMENTATION IS OUT-OF-DATE. Updated documentation is coming soon.

The Cortex-Debug extension has capabilities to decode and display ITM trace data from the SWO output on supported microcontrollers (Cortex-M3, Cortex-M4, and Cortex-M7 cores have ITM capabilities). Each of the up-to 32 ports can be configured and displayed independently, either as text (console) output stream, or as decoded binary data (currently signed and unsigned 32-bit integers, and signed Q16.16 fixed point values are supported).

Additionally, decoded binary data can be fed to a graphing system which will plot the decoded data in real-time as it is received from the microcontroller.

SWO Decoding Configuration

The swoConfig parameter is a JSON object with the following properties:

  • enabled: This is a master enable for the entire SWO decoding system - if this parameter is false (or omitted) then SWO output and decoding will not be enabled, and all other configuration options will be ignored.
  • swoFrequency: The frequency of the SWO output in Hz. A value of 0 can be used here to attempt automatic configuration; if this does not function as desired then you will need to supply the value based upon your target device configuration.
  • cpuFrequency: The frequency of the target processing core in Hz. A value of 0 can be used here to attempt automatic configuration; if this does not function as desired then you will need to supply the value based upon your target device configuration.
  • ports: A array of objects configuring each of the ITM ports to be used. Data output on ports not configured in this array will be discarded.

Each port configuration has the following configuration options:

  • number: The ITM port number (0 to 31)
  • label: A label for the output view in Visual Studio Code (final name for the output will follow the format
    SWO: <label> [port: <number>, format:<format>]
  • format: The format for the output; this should be one of the following values:
    • console - decode the output as text and display. Each port configured will have a separate output view added to visual studio code
    • binary - decode the output as binary data, displaying it in the console (each value on a separate line - with the following format:
      [<timestamp>] <raw hex> <decoded value> <scaled value>
    • graph - decode the output as binary data, and feed it into the graphing system
  • encoding: The encoding for binary data (only used with format of graph or binary); this can be one of the following values:
    • unsigned (default) - An unsigned 32-bit integer
    • signed - A signed 32-bit integer
    • Q16.16 - A signed fixed point integer, with 16 bits used for both the integer and fractional portions.
  • scale: A scaling factor to be applied to the decoded data before display/graphing; this could be used for example to convert raw data values to real-world values. e.g. to convert a raw 10-bit ADC reading into a voltage (0 to 3.3v range) a scale value of 3.3/1024 = 0.00322265625 could be used 

Graphing Configuration

Please check back later for graphing configuration information.