I/O Retargeting  Version 1.2.0
User Code Templates for I/O Retargeting using ARM Compiler
 All Files Macros Pages
Retarget Output via ITM

Copy the USB Host Keyboard example application to your PC as described in Retarget Input via Keyboard and Output via Display. To change the retarget option for STDOUT to ITM, open the Manage Run-Time Environment window and set the Variant as shown here:

SelITMOutput.png
Select ITM as Output Channel

This will change the #defines in the RTE_Components.h file and thus execute another code section in retarget_io.c. Adapting the code is not required. The code in the file stdout_display.c is now disabled because of the new #defines. Sending data via the ITM channel does not require additional code.

Configure your debug adapter for tracing and enable the ITM channel 0 as described in ITM Stimulus Ports.

Build the project, download it to the target, and start a debug session. Open the Debug (printf) Viewer window (View -> Serial Windows -> Debug (printf) Viewer) to observe the application's output. Input is still coming from the USB keyboard.

ITMOutput.png
Output redirected to Debug (printf) Viewer