260
SAM4CP [DATASHEET]
43051E–ATPL–08/14
13.7.5 DWT (Data Watchpoint and Trace)
The DWT contains four comparators which can be configured to generate the following:
PC sampling packets at set intervals.
PC or Data watchpoint packets.
Watchpoint event to halt core.
The DWT contains counters for the items that follow:
Clock cycle (CYCCNT).
Folded instructions.
Load Store Unit (LSU) operations.
Sleep Cycles.
CPI (all instruction cycles except for the first cycle).
Interrupt overhead.
13.7.6 ITM (Instrumentation Trace Macrocell)
The ITM is an application driven trace source that supports printf style debugging to trace Operating System (OS) and
application events, and emits diagnostic system information. The ITM emits trace information as packets which can be
generated by three different sources with several priority levels:
Software trace
: Software can write directly to ITM stimulus registers. This can be done thanks to the “printf”
function. For more information, refer to
Section 13.7.6.1 “How to Configure the ITM”
.
Hardware trace
: The ITM emits packets generated by the DWT.
Time stamping
: Timestamps are emitted relative to packets. The ITM contains a 21-bit counter to generate the
timestamp.
13.7.6.1 How to Configure the ITM
The following example describes how to output trace data in asynchronous trace mode.
Configure the TPIU for asynchronous trace mode (refer to
Section 13.7.6.3 “How to Configure the TPIU”
).
Enable the write accesses into the ITM registers by writing “0xC5ACCE55” into the Lock Access Register
(Address: 0xE0000FB0).
Write 0x00010015 into the Trace Control Register:
Enable ITM
Enable Synchronization packets
Enable SWO behavior
Fix the ATB ID to 1
Write 0x1 into the Trace Enable Register:
Enable the Stimulus port 0
Write 0x1 into the Trace Privilege Register:
Stimulus port 0 only accessed in privileged mode (Clearing a bit in this register will result in the
corresponding stimulus port being accessible in user mode)
Write into the Stimulus port 0 register: TPIU (Trace Port Interface Unit)
The TPIU acts as a bridge between the on-chip trace data and the Instruction Trace Macrocell (ITM).
The TPIU formats and transmits trace data off-chip at frequencies asynchronous to the core.