To carry out SWO Trace on LPC13xx, it is necessary to:
This should typically be done within each of your application projects (or library projects that your projects link against).
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.
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.
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.
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;
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;