Configure Cortex-M ITM Trace for printf() Debugging
In this topic:
This how-to guide focuses on the Software Tracing on Arm Cortex-M architecture using the Instrumentation Trace Macrocell (ITM). It explains the use case of printf() output, including how to configure the Terminal Window and display the data.
By using the Cortex-M ITM, the application can “print” optional data to the Terminal window. Code is instrumented with “trace points”, which provide an insight into the embedded target behavior at full MCU speed and without stopping the execution. BlueBox captures and decodes it, and then displays a human-readable string in the Terminal window. Writing one data within the application “trace point” requires a single write cycle to the internal 32-bit register which yields negligible performance penalty.
•winIDEA
•Build Manager
•BlueBox
•Target Board with Arm Cortex-M SoC featuring the ITM and the SWO output
Add the code snippet to your Application. |
#include " core_cm4.h" |
Build your project. |
You can use CMake, which is integrated into winIDEA.
Open Hardware | CPU Options | SoC and select: |
•SWD Debug Protocol
•Parallel or SWO Trace Capture method
Make sure to perform a Trace Line Calibration if using the Parallel Trace Capture method. |
Go to View | Workspace | Terminal Window | Options and click Configure. |
Select Trace Channel as Communication type and click Advanced. |
Select the ITM Stimuli. |
From the Enable dropdown select either:
•All
•Selected and one ITM Stimuli is enabled, e.g. ITM (0).
Perform a Debug Download. |
Click on the Connect button in the Terminal window and run the application. |
The results will be shown in the Terminal window.
•Instrumentation Trace Macrocell (ITM)