Cortex-M Debug and Trace
Cortex-M processor-based devices use the ARM CoreSight™ technology which introduces powerful new debug and trace capabilities.
- Run Control of the processor allowing you to start and stop programs
- Single Step one source or assembler line
- Set breakpoints while the processor is running
- Read/write memory contents and peripheral registers on-the-fly
- Program internal and external FLASH memory
- Serial Wire Viewer (SWV) provides PC Sampling, data trace, event trace, and instrumentation trace information
- Instruction (ETM) Trace streamed directly to your PC enabling debugging of historical sequences, software profiling, and code coverage analysis
The CoreSight features are available via JTAG and new Serial Wire interfaces using standard low-cost target connectors.
Cortex-M3 JTAG and Serial Wire Debug Modes
JTAG is the industry-standard interface used to download and debug progams on a target processor, as well as many other functions. It offers a convenient and easy way to connect to devices and is available on all ARM processor-based devices.
The JTAG interface can be used with Cortex-M devices to access the CoreSight debug capabilities.
Serial Wire Debug (SWD)
The Serial Wire Debug mode is an alternative to the standard JTAG interface.
SWD uses 2-pins to provide the same debug functionality as JTAG with no performance penalty, and introduces data trace capabilities with the Serial Wire Viewer (SWV).
The SWD interface pins can be overlayed with the JTAG signals, allowing the standard target connectors to be used.
- TCLK - SWCLK (Serial Wire Clock)
- TMS - SWDIO (Serial Wire debug Data Input/Output)
- TDO - SWO (output pin for Serial Wire Viewer. See next section)
JTAG and SWD modes are fully supported by ULINK2, ULINK-ME, and ULINKPro.
Serial Wire Viewer (SWV)
Cortex-M3 and Cortex-M4 based devices are able to provide high-speed data trace information in a number of ways depending on the type of information or analysis you require.
The Serial Wire Viewer (SWV) provides real-time data trace information from various sources within the Cortex-M3/M4 device. This is output via the single SWO pin while your system processor continues running at full speed.
Information is available from the ITM (Instrumentation Trace Macrocell) and DWT (Data Watchpoint and Trace) units, providing:
- 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
- ITM trace information used for simple printf-style debugging
SWV Data trace is available via the SWO pin in two output formats:
- UART style (1Mb/s) - supported by ULINK2 and ULINK-ME
- Manchester Encoded (100Mb/s) - supported by ULINKPro
- Data trace via Serial Wire Viewer (SWV) is not available using the JTAG interface. SWV is only available when using Serial Wire Debug mode.
Embedded Trace Macrocell (ETM)
Cortex-M3 Embedded Trace Macrocell
The Embedded Trace Macrocell provides high bandwidth Instruction Trace via four dedicated trace pins accessible on the 20-pin Cortex debug connector. This enhanced trace capability records instruction by instruction program execution which can be used for:
- Debugging historical sequences leading up to events of interest
- Software profiling and algorithm optimization
- Code coverage analysis
- ETM instruction trace is only supported by ULINKPro.
- The ETM optionally available on Cortex-M3 and Cortex-M4 processor-based microcontrollers. It is not available on Cortex-M0, M0+ and M1.
The Keil µVision IDE and Debugger supports Cortex-M devices with dedicated windows which display debug information, trace records, state changes, and instruction trace.
Trace Records windows display the trace information in real-time
There are several target connectors available for connecting to an ARM target system:
- 10-pin (0.05") - Cortex Debug Connector
- 20-pin (0.10") - ARM Standard JTAG Connector
- 20-pin (0.05") - Cortex Debug+ETM Connector