This FAQ provides an overview of the various forms of trace available within the LPCXpresso IDE:
- SWO Trace
- Instruction Trace
For more details, please see the LPCXpresso User Guide installed within the product.
SWO (Serial Wire Output) is a pin on the Cortex-M3/M4 debug interface that provides the means of accessing real-time trace information from various sources within the Cortex-M3/M4 cpu. The debugger can process this data to provide SWO Trace views such as:
Execution profiles from PC (Program Counter) sampling
Event counters that show CPU cycle statistics
Exception and Interrupt execution with timing statistics
Trace data - data reads and writes used for timing analysis.
Printf output via the Instrumentation Trace Macrocell (ITM) block (LPCXpresso v8 only).
Note : SWO Trace is also often referred to as Serial Wire Viewer (SWV).
LPCXpresso IDE v7.7 and later provide increasing levels of SWO Trace functionality via the LPC-Link2 debug probe, both the standalone probe and also the version built into the LPCXpresso V2/V3 boards. [Note that in LPCXpresso IDE v7.7 this was only via the "Redlink" LPC-Link2 firmware, but later versions work using CMSIS-DAP firmware.]
SWO Trace is supported by LPCXpresso IDE for all NXP LPC MCUs based on Cortex-M3/M4 cpus, including LPC1300, LPC1500, LPC1700, LPC1800, LPC407x_8x, LPC4300 (M4 only) and LPC5410x.
Note that the SWO pin from the MCU must be accessible via the debug connector in order for the LPCXpresso IDE to provide SWO trace capability.
What level of SWO Trace functionality is available depends upon which LPCXpresso variant you are using:
- LPCXpresso IDE Free Edition supports Profile Trace and Interrupt Statistics, together with 1x data watch trace. ITM Printf is also supported in LPCXpresso IDE v8.
- LPCXpresso IDE Pro Edition provides the same support as the Free edition, but increases the number of data watch trace items from 1 to 4 (the maximum supported by the Cortex-M debug architecture).
You may start collecting SWO Trace information at any time whilst debugging your application, not just if you are stopped at a breakpoint.
Important note for Mac Users
There is currently an issue with SWO Trace support on Mac OS X hosts such that if LPCXpresso IDE as been started from Launchpad, or by clicking on the lpcxpresso.app, then SWO Trace may not work. In such cases, LPCXpresso IDE will attempt to warn you that a problem has been seen by outputing a message including:
"On Mac LPCXpresso may need to be started using the 'Open lpcxpresso' link to use SWO functionality"
and you should then try launching LPCXpresso IDE by clicking on the "install_dir/Open lpcxpresso" alias (or by running it from a terminal).
General configuration requirements for SWO Trace
SWD vs JTAG
SWO Trace functionality is only available when connecting to the target MCU using SWD. If you are connected via JTAG, you will see an error message when you try to start SWO Trace saying:
"SWD debug connection required to use SWO Trace. JTAG debug connection was detected."
For most Cortex M3/M4 MCUs, debug connections are made using SWD by default. However with LPC43xx parts, JTAG is used by default, so you will need to switch to using SWD.
Before collecting data, SWO Trace asks for the configuration of your target. The target clock speed has to match the actual clock speed of the MCU. If the clock speed setting does not match the actual clock speed of the processor, either no trace data will be displayed or any trace data displayed will be garbage.
Note that SWO Trace can automatically detect the current clock speed from the SystemCoreClock global variable (which will generally defined in LPCOpen projects). However in some cases, depending upon what point you try to start carrying out SWO Trace, this variable may not yet have been initialized (typically done by a call to the function SystemCoreClockUpdate() ). In such cases, you will either need to enter the appropriate value manually, or else allow SystemCoreClockUpdate() to excute first. Once set, the clock setting for a project is stored by the LPCXpresso IDE for use in future debug sessions.
Part specific configuration for SWO Trace
Some MCUs require initialization code to setup the MCU to allow SWO trace to function, typically because the trace clock is not enabled by default and the SWO signal is not on a dedicated pin and so requires appropriate pinmux'ing. For more details, please see:
For other parts, care needs to be taken when configuring the debug connection and setting up the clock configuration. For more details, please see:
Additional SWO Trace information
Instruction trace provides the ability to record and review the sequence of instructions executed on a target. The LPCXpresso IDE provides support for instruction trace via on chip trace buffers - the Embedded Trace Buffer (ETB) on MCUs based on the Cortex M3/M4 cpu and the Micro Trace Buffer (MTB) on MCUs based on the Cortex-M0+ cpu. The instruction trace information, which is generated at high speed within the cpu, can be captured in real time and stored in these on-chip buffers and then be downloaded at lower speeds without the need for expensive external trace capture box.
Instruction trace is supported by the LPCXpresso IDE with the following MCUs, using any of the primary supported debug probes with both SWD and JTAG debug connections (where supported by the target MCU):
LPC8xx (Cortex-M0+ with MTB)
LPC11U6x / LPC11UE6x (Cortex-M0+ with MTB)
LPC18xx (Cortex-M3 with ETM+ETB)
LPC43xx (Cortex-M4 with ETM+ETB)
Note that instruction trace is not supported with LPC17xx MCUs (which do not implement an ETB) or LPC13xx/LPC15xx MCUs (which do not implement ETM or ETB).
In order to begin collecting instruction trace records, execution of the target MCU must be paused so that the target can be configured. It must be paused again to download the trace records for display within the debugger.
There are no constraints or setup issues related to clock speed when using Instruction Trace.
"Red Trace" was the name of an earlier generation of SWO trace functionality in the LPCXpresso IDE when using the legacy Red Probe+ debug probe. Red Trace support was removed from LPCXpresso IDE in v8.1.0.