Example Summary

Example that uses the Instrumentation Trace Macrocell (ITM) hardware to write software instrumentation messages to the PC.

These messages can be read using a suite of tools available in CCS, IAR, or standalone tools.

Peripherals Exercised

BoosterPacks, Board Resources & Jumper Settings

For board specific jumper settings, resources and BoosterPack modifications, refer to the Board.html file.

If you’re using an IDE such as Code Composer Studio (CCS) or IAR, please refer to Board.html in your project directory for resources used and board-specific jumper settings.

The Board.html can also be found in your SDK installation:

<SDK_INSTALL_DIR>/source/ti/boards/<BOARD>

Example Usage

Expected Output

When running the tool and resetting the board, this is an example of expected output:

> tilogger_itm_viewer COM62 12000000
INFO:Serial Rx:Serial port \\.\COM62 @ 12000000 opened
SW SWIT at +0, port STIM_DRIVER: 0xBB 0xBB 0xBB 0xBB
SW SWIT at +0, port STIM_RESV0: 0x48 0x65 0x6C 0x6C
TIMESTAMP in sync: + 169 cycles
SW SWIT at +169, port STIM_RESV0: 0x6F 0x20 0x57 0x6F
Unknown/Reserved timestamp header: 16
SW SWIT at +0, port STIM_RESV0: 0x72 0x6C 0x64 0x20
Unknown/Reserved timestamp header: 16
SW SWIT at +0, port STIM_RESV0: 0x66 0x72 0x6F 0x6D
SW SWIT at +0, port STIM_RESV0: 0x20 0x49 0x54 0x4D
SW SWIT at +0, port STIM_RESV0: 0x00
TIMESTAMP packet and timestamp delayed: + 34 cycles
TIMESTAMP in sync: + 1999999 cycles
HW Trace at 1999.999, Read Access, comparator: 0, value : 0x0
TIMESTAMP in sync: + 1030325 cycles
HW Trace at 1030.325, Write Access, comparator: 0, value : 0x1
TIMESTAMP in sync: + 1999999 cycles
HW Trace at 1999.999, Read Access, comparator: 0, value : 0x1
TIMESTAMP in sync: + 1020673 cycles
HW Trace at 1020.673, Write Access, comparator: 0, value : 0x2
TIMESTAMP in sync: + 1999999 cycles
HW Trace at 1999.999, Read Access, comparator: 0, value : 0x2
TIMESTAMP in sync: + 1020757 cycles
HW Trace at 1020.757, Write Access, comparator: 0, value : 0x3

First, we can see the reset frame 0xBB 0xBB 0xBB 0xBB.

Then we see a series of hex values interleaved with timestamps. These values match the expected hex output for “Hello World from ITM”:

 H    e    l    l    o         W    o    r    l    d
0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20

 f    r    o    m         I    T    M
0x66 0x72 0x6F 0x6D 0x20 0x49 0x54 0x4D 0x00

After this we see only the HW Trace packets. These are messages from the DWT Watchpoint module, which is tracking accesses to variableToWatch, which is accessed periodically by clockTimeoutFunction.

The lines indicating Unknown/Reserved timestamp are a limitation with the current tooling.

Host Side Tooling

Several IDEs such as IAR or CCS offer ITM focused tooling. These tools will configure the ITM registers directly through the debugger. This example will configure the ITM on device from firmware. For this reason, this example will not be compatible with these tools as the configuration settings may clash.

If it is desired to use these tools, it is recommended to comment out any APIs related to ITM configuration (e.g. ITM_open, ITM_close, ITM_enable*, ITM_disable*) and use ITM_applyPinMux directly to mux out the SWO pin.

From there, the settings and configuration of ITM is configured by the IDE. However the SW message APIs can be used to write to the stimulus ports.

SysConfig

The ITM driver parameters such as serial format, baud rate, and trace port enable can be configured in SysConfig. When enabled, the ITM driver will hook into the Power policy using ITM_flush and ITM_restore to ensure that all pending messages are flushed before the device powers down the CPU domain.

Application Design Details

FreeRTOS: