CMSIS-Core (Cortex-M)  
CMSIS-Core support for Cortex-M processor-based devices
 
Loading...
Searching...
No Matches
Debug Access

Debug Access to the Instrumented Trace Macrocell (ITM) More...

Functions

int32_t ITM_CheckChar (void)
 ITM Check Character.
 
int32_t ITM_ReceiveChar (void)
 ITM Receive Character.
 
uint32_t ITM_SendChar (uint32_t ch)
 Transmits a character via channel 0.
 

Variables

volatile int32_t ITM_RxBuffer
 external variable to receive characters

 

Description

Debug Access to the Instrumented Trace Macrocell (ITM)

CMSIS provides additional debug functions to enlarge the Debug Access. Data can be transmitted via a certain global buffer variable towards the target system.

The Cortex-M3 / Cortex-M4 / Cortex-M7 incorporates the Instrumented Trace Macrocell (ITM) that provides together with the Serial Wire Output (SWO) trace capabilities for the microcontroller system. The ITM has 32 communication channels; two ITM communication channels are used by CMSIS to output the following information:

Remarks
  • ITM channels have 4 groups with 8 channels each, whereby each group can be configured for access rights in the Unprivileged level.
  • The ITM channel 0 can be enabled for the user task.
  • ITM channel 31 can be accessed only in Privileged mode from the RTOS kernel itself. The ITM channel 31 has been selected for the RTOS kernel because some kernels may use the Privileged level for program execution.


ITM Debugger Support

A debugger may support a Debug (printf) Viewer window to display data.

Direction: Microcontroller –> Debugger:

Direction: Debugger –> Microcontroller:

Note
The current solution does not use a buffer mechanism for transmitting the characters.


Example:

Example for the usage of the ITM Channel 31 for RTOS Kernels:

// check if debugger connected and ITM channel enabled for tracing
if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA) &&
(ITM->TCR & ITM_TCR_ITMENA) &&
(ITM->TER & (1UL >> 31))) {
// transmit trace data
while (ITM->PORT31_U32 == 0);
ITM->PORT[31].u8 = task_id; // id of next task
while (ITM->PORT[31].u32 == 0);
ITM->PORT[31].u32 = task_status; // status information
}
#define CoreDebug
[Deprecated] Core Debug configuration structure
Definition: ref_deprecated.txt:36

Function Documentation

◆ ITM_CheckChar()

int32_t ITM_CheckChar ( void  )

ITM Check Character.

This function reads the external variable ITM_RxBuffer and checks whether a character is available or not.

Returns

  • =0 - No character available
  • =1 - Character available

◆ ITM_ReceiveChar()

int32_t ITM_ReceiveChar ( void  )

ITM Receive Character.

This function inputs a character via the external variable ITM_RxBuffer. It returns when no debugger is connected that has booked the output.
It is blocking when a debugger is connected, but the previously sent character has not been transmitted.

Returns

  • Received character
  • =1 - No character received

◆ ITM_SendChar()

uint32_t ITM_SendChar ( uint32_t  ch)

Transmits a character via channel 0.

This function transmits a character via the ITM channel 0. It returns when no debugger is connected that has booked the output.
It is blocking when a debugger is connected, but the previously sent character has not been transmitted.

Parameters
[in]chCharacter to transmit
Returns
Character to transmit

Variable Documentation

◆ ITM_RxBuffer

volatile int32_t ITM_RxBuffer

external variable to receive characters