This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf ITM with RTX RTOS

Hello all,

I am having an issue with using the 'Debug (printf) Window' to display debugging messages as the code runs. Upon startup I print simple initialization messages using the printf function which displays an index(printIndex) or count of the message that is being printed and the message(msg) itself.

printf("%003u - L: %s\r\n",printIndex++, msg);

Most of these messages are display in the 'Debug (printf) Window' but not all of them, some are missed. If I set a breakpoint after printf() then all messages are displayed.

After the RTOS threads start up and begin to perform their tasks the printf() function the likelihood of getting printf() message is even worse and I will see erroneous characters and spaces get printed to the 'Debug (printf) Window'.

My guess is that there is a timing issue between the RTOS and the ITM debugging port.

I am using a ULINK2/ME Cortex Debugger, settings are;
Debug
SWJ: Checked
Port: SW
Max Clock: 500kHz (I have tried various speeds without any change in the results)

Trace
Trace Port
Core Clock: 16.384MHz (My HSE freq)
Trace Enable: Checked
SWO Clock Prescalar: 14 (Autodetect: Checked)
SWO Clock: 1.170285MHz

Timestamps
Enable: Checked
Prescalar: 1

Trace Events
SLEEP: Sleep Cycles: Checked
EXCTRC: Exception Tracing: Checked

ITM Stimulus Ports
Enable: 0x00000001
Privilege: 0x00000008

In 'Manage Run-Time Environment' I have selected the following:
CMSIS
-CORE (5.0.1)
-RTOS(API) (1.0.0) Keil RTX (4.81.1)

Compiler (1.2.0)
-I/O
STDERR: ITM (1.2.0)
STDIN: ITM (1.2.0)
STDOUT: ITM (1.2.0)

Device
Startup (1.2.0)

Graphics
CORE (5.36.6)

Thanks in advance for your help,
Tim