cancel
Showing results for 
Search instead for 
Did you mean: 

Need a help About ITM_Sendchar

Asraful
Associate III

i can use ITM_SendChar with printf by overriding __io_putchar but currently i am working with C++ is there any way to use ITM_SendChar with cout? if there any can anyone please tell me how to do that or provide the code for that.

Thanks in Advance

1 REPLY 1
Pavel A.
Evangelist III

Eventually all these stdio functions , either for C or C++ sink down to  the _write "system call". So you'll need to implement the _write rather than __io_putchar. The 1st arg of _write is the "file descriptor" number. As usual 0= stdin or cin (not writable, of course), 1=stdout or cout, 2=stderr or cerr & clog. You can define more custom descriptors from 3 up.

Note that ITM itself has multiple sub-channels, 0 is the default "ITM print"; the CMSIS function ITM_Sendchar sends to this channel. In CubeIDE you can open more ITM windows for channels 1,2 etc. and send  output of each C/C++ handle to separate ITM channels -> IDE windows. For this you implement replacement of ITM_Sendchar.

Good luck!