MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

/*! More...

Serial wire output is a mechanism for ARM targets to output signal from core through a single pin. Some IDE support SWO also, such IAR and KEIL, both input and output are supported, reference below for detail.

Guide SWO for SDK

NOTE: After the setting both "printf" and "PRINTF" are available for debugging, JlinkSWOViewer can be used to capture the output log.

Step 1: Setting up the environment

  1. Define DEBUG_CONSOLE_IO_SWO in your project settings.
  2. Prepare code, the port and baudrate can be decided by application, clkSrcFreq should be mcu core clock frequency:
    DbgConsole_Init(port, baudrate, DEBUG_CONSOLE_DEVICE_TYPE_SWO, clkSrcFreq);
  3. Use PRINTF or printf to print some thing in application.

    Step 2: Building the project

Step 3: Download and run project

Guide SWO for IAR

NOTE: After the setting both "printf" and "scanf" are available for debugging.

Step 1: Setting up the environment

  1. Choose project -> "Options" -> "Debugger" -> "J-Link/J-Trace".
  2. Choose tab "J-Link/J-Trace" -> "Connection" tab -> "SWD".
  3. Choose tab "General Options" -> "Library Configurations", select Semihosted, select Via SWO.
  1. Make sure the SDK_DEBUGCONSOLE_UART is not defined, remove the default definition in fsl_debug_console.h..
  1. Start the project by choosing Project>Download and Debug.

    Step 2: Building the project

Step 3: Starting swo

  1. Download and debug application.
  2. Choose View -> Terminal I/O to display the output from the I/O operations.
  3. Run application.

Guide SWO for Keil µVision

NOTE: After the setting both "printf" and "scanf" are available for debugging.

Step 1: Setting up the environment

  1. Make sure the SDK_DEBUGCONSOLE_UART is not defined, remove the default definition in fsl_debug_console.h.
  2. In menu bar, click Management Run-Time Environment icon, select Compiler, unfold I/O, enable STDERR/STDIN/STDOUT and set the variant to ITM.
  3. Open Project>Options for target or using Alt+F7 or click.
  4. Select “Debug” tab, select “J-Link/J-Trace Cortex” and click “Setting button”.
  5. Select “Debug” tab and choose Port:SW, then select "Trace" tab, choose "Enable" and click OK, please make sure the Core clock is set correctly, enable autodetect max SWO clk, enable ITM Stimulus Ports 0.

Step 3: Building the project

  1. Compile and link the project by choosing Project>Build Target or using F7.

Step 4: Run the project

  1. Choose “Debug” on menu bar or Ctrl F5.
  2. In menu bar, choose "Serial Window" and click to "Debug (printf) Viewer".
  3. Run line by line to see result in Console Window.

Guide SWO for MCUXpresso IDE

NOTE: MCUX support SWO for LPC-Link2 debug probe only.

Guide SWO for ARMGCC

NOTE: ARMGCC has no library support SWO.