Debugger Features
User Guide
© 2023 Microchip Technology Inc. and its subsidiaries
DS-50003529B - 52
3. If using the adapter board, connect the trace cable between the adapter board and trace
connector on your target board.
4. Power the target.
5.4.5 Set Up ITM in MPLAB X IDE
An MPLAB X IDE project is needed for code development and debugging. Then project can be
congured for debug tool feature support.
5.4.5.1 Create a Project in MPLAB X IDE
Create a project in MPLAB X IDE while being mindful of the 5.4.3. Requirements for ITM/SWO Trace.
For more on creating a project, consult MPLAB X IDE documentation.
To assist with code development, consider using MCC MPLAB Harmony:
1. Select Tools>Plugins>Available Plugins>MPLAB Code Congurator and click Install. MPLAB X IDE will
need to restart.
2. Click on the toolbar icon. Please wait for MCC to initialize and install.
3. On the Content Manager tab, click to Select MPLAB Harmony.
4. Ensure Required Content is downloaded and select any Optional Content needed for your
application. Then click Finish.
5. Edit main() and other les as necessary to create your application.
5.4.5.2 Use CMSIS ITM Funcons
Right click on the project name in the Projects window and select “Properties.” Under Packs, in
addition to the device pack (DFP), CMSIS is also included (see gure below).
The Common Microcontroller Software Interface Standard (CMSIS) is a vendor-independent
abstraction layer for microcontrollers that are based on Arm Cortex processors. CMSIS denes
generic tool interfaces and enables consistent device support. The CMSIS software interfaces
simplify software reuse, reduce the learning curve for microcontroller developers, and improve time
to market for new devices.
The ARM CMSIS package comes with specic header les/APIs for sending ITM data. For example, in
<MPLAB_Installation>packs\arm\CMSIS\x.x.x\CMSIS\Core\Include\core_cm7.h,
nd the CMSIS function ITM_SendChar() that can be used to print a character over ITM/SWO:
__STATIC_INLINE uint32_t ITM_SendChar(uint32_t ch)
These are the lowest level APIs at the byte level (only writing to PORT 0); however you can customize
and develop your own functions for printing the messages to any port 0 through 31 (see 5.4. ARM
ITM/SWO Trace).
__STATIC_INLINE uint32_t ITM_SendCharPort (uint8_t port, uint32_t ch)
{
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
((ITM->TER & 1UL << port ) != 0UL) ) /* ITM Port enabled */
{
while (ITM->PORT[port].u32 == 0UL)
{