146
*
**********************************************************************
----------------------------------------------------------------------
File
: SWO.c
Purpose : Simple implementation for output via SWO for Cortex-M processors.
It can be used with any IDE. This sample implementation ensures that
output via SWO is enabled in order to gurantee that the application
does not hang.
--------
END-OF-HEADER
*/
/*********************************************************************
*
*
Prototypes (to be placed in a header file such as SWO.h)
*/
void SWO_PrintChar
void SWO_PrintString(const char *s);
/*********************************************************************
*
*
Defines for Cortex-M debug unit
*/
#define ITM_STIM_U32 (*(volatile unsigned int*)0xE0000000) // STIM word access
#define ITM_STIM_U8
#define ITM_ENA
#define ITM_TCR
/*********************************************************************
*
*
SWO_PrintChar()
*
* Function description
*
Checks if SWO is set up. If it is not, return,
*
to avoid program hangs if no debugger is connected.
*
If it is set up, print a character to the ITM_STIM register
*
in order to provide data for SWO.
* Parameters
*
c:
The Chacracter to be printed.
* Notes
*
Additional checks for device specific registers can be added.
*/
void SWO_PrintChar(char c) {
//
// Check if ITM_TCR.ITMENA is set
//
if ((ITM_TCR & 1) == 0) {
return;
}
//
// Check if stimulus port is enabled
//
if ((ITM_ENA & 1) == 0) {
return;
}
//
// Wait until STIMx is ready,
// then send data
//
while ((ITM_STIM_U8 & 1) == 0);
ITM_STIM_U8 = c;
}
J-Link / J-Trace (UM08001)
CHAPTER 3
---------------------------------------------
(char c);
(*(volatile
(*(volatile unsigned int*)0xE0000E00) // ITM Enable Reg.
(*(volatile unsigned int*)0xE0000E80) // ITM Trace Control Reg.
J-Link software and documentation package
char*)0xE0000000) // STIM Byte access
© 2004-2017 SEGGER Microcontroller GmbH & Co. KG
*
Need help?
Do you have a question about the J-Link and is the answer not in the manual?
Questions and answers