NOTICE: This website will be shut down in the near future. Product content has moved to Forum content and FAQs have been moved to We encourage you to create a user account on to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.


SWO Trace setup for LPC5410x

lpcxpresso-support's picture

To carry out SWO Trace on LPC5410x, it is necessary to

  1. Ensure that your board has SWO pinned out to the debug connector
  2. If using the built-in LPC-Link2 debug probe of a LPCXpresso54102 board, ensure that the probe is configured for DFU booting
  3. Turn on the trace clock within the MCU, as this is not enabled by default
  4. Configure the MCU pinmuxing, so that the SWO signal is accesible on the appropriate pin of the MCU

This should typically be done within each of your application projects (or library projects that your projects link against).

Note that SWO Trace on LPC5410x MCUs can only be carried out for debug sessions connected to the Cortex-M4 CPU, not to the Cortex-M0+.

SWO pin and debug connector

On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector.

If you are using a different board, you will need to check the schematics to identify if SWO is connected to the debug connector (and on which pin from the MCU).

Debug probe

The LPCXpresso54102 board is typically shipped with CMSIS-DAP firmware installed into the built-in LPC-Link2 debug probe that does not provide the necessary channels for SWO trace data transfer back to the host debugger. You need to configure your board so that the LPCXpresso IDE can softload "redlink" firmware. This is done by fitting a jumper on JP5, then repowering the board. For more details, please see

Enabling the trace clock

The startup code generated by the new project wizards for LPC5410x in LPCXpresso IDE v7.7 (and later) contain code to optionally turn on the trace clock.  By default this code will be enabled by the new project wizard, but if not required can be removed by defining the compiler symbol DONT_ENABLE_SWVTRACECLK.

If you are using different startup code (for instance, as provided in the projects in the LPCOpen v2.14.1 package for the LPCXpresso5410x board), then you can add the following code to your project to turn on the trace clock  (for example right at the start of main() or in the startup file before the call to main() ) :

volatile unsigned int *TRACECLKDIV = (unsigned int *) 0x400000E4;
volatile unsigned int *SYSAHBCLKCTRLSET = (unsigned int *) 0x400000C8;
// Write 0x00000001 to TRACECLKDIV (0x400000E4) – Trace divider
// Enable IOCON peripheral clock (for SWO on PIO0-15 or PIO1_1)
// by setting bit13 via SYSAHBCLKCTRLSET[0] (0x400000C8)
*SYSAHBCLKCTRLSET = 1 << 13; // 0x2000

Note that later versions of the LPCOpen package for LPC5410x should contain appropriate trace clock setup code in the startup file.

SWO pinmux configuration

On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector. This needs configuring in the pinmux settings for your project.

If you are using the examples from the LPCOpen v2.14.1 package for the LPCXpresso5410x board, then you need to modify the pinmux settings in board_sysinit.c of the lpc_board_lpcxpresso_54102 library project, so that the SWO settings are not commented out by the #if 0 ... #endif clause (as they are by default). Thus after modifying the code, it should look like:

 #if 0  /* Debugger signals, do not touch */

Note that later versions of the LPCOpen package for LPC5410x should contain appropriate SWO pinmux setup code for the LPCXpresso54102 board in the board library.

For more information:

Your rating: None