NOTICE: This website will be shut down in the near future. Product content has moved to nxp.com. Forum content and FAQs have been moved to community.nxp.com. We encourage you to create a user account on nxp.com 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 LPC13xx

lpcxpresso-support's picture

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

  1. Ensure that your board has SWO pinned out to the debug connector
  2. Turn on the trace clock within the MCU, as this is not enabled by default
  3. 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).

SWO pin and debug connector

On LPC13xx parts, the SWO signal is accessible via pin P0_9  of the MCU. Thus you will need to check the schematic for you board to ensure that SWO is connected to the debug connector.

Enabling the trace clock

The current startup code generated by the new project wizards for LPC13xx parts in LPCXpresso IDE v7.7 (and earlier) does not yet contain code to optionally turn on the trace clock. This is intended for a future LPCXpresso IDE release. In the meantime, you can use the code below for doing this.

SWO pinmux configuration

On LPC13xx parts, the SWO signal is accessible via pin P0_9  of the MCU

Thus the pinmux settings for your project need to ensure that this pin is configured to use the SWO function. In particular this means that this pin is no longer available for use as the MOSI0 for the SSP0 peripheral. Example code to do this is given below.

Note that the default LPCOpen codebase for LPC1343 and LPC1347 setup P0_9 as MOSI0 in board_sysinit.c of their board ibrary project.

Example setup code for LPC1315/16/46/47 parts

Adding the following code to your main() function, after the call to Board_Init() if using LPCOpen, should allow SWO trace to function:

volatile unsigned int *TRACECLKDIV = (unsigned int *) 0x400480AC;
volatile unsigned int *IOCON_PIO_0_9 = (unsigned int *) 0x40044024;
// Write 1 to TRACECLKDIV  – Trace divider
*TRACECLKDIV = 1;
// Write 0x93 to I/O configuration for pin PIO0_9 to select ARM_TRACE_SWV
*IOCON_PIO_0_9 = 0x93;

Example setup code for LPC1311/13/42/43 parts

Adding the following code to your main() function, after the call to Board_Init() if using LPCOpen, should allow SWO trace to function:

volatile unsigned int *TRACECLKDIV = (unsigned int *) 0x400480AC;
volatile unsigned int *IOCON_PIO_0_9 = (unsigned int *) 0x40044064;
// Write 1 to TRACECLKDIV  – Trace divider
*TRACECLKDIV = 1;
// Write 0x93 to I/O configuration for pin PIO0_9 to select ARM_TRACE_SWV
*IOCON_PIO_0_9 = 0x93;


For more information:

0
Your rating: None
feedback