The following code captures only 2 characters, than it stops capturing on MacOS.. For instance, if user presses "abc" and presses enter, only ab is captured. Than ITM_ReceiveChar always returns -1..
int i = 0;
while (i < 100)
int c = ITM_ReceiveChar();
if (c == -1)
if (c == 'A')
if (c == 'S')
The code works OK in Windows.. Additionaly, if the code starts transmitting characters on very first instance of the boot through ITM port 0, the ITM Console clears out the incomming data.. Adding 2 seconds of delay to the code fixes that problem but it is inconvenient..
Btw: Transmitting with enter, and echoing is a little discomforting. I implemented shell interface with history, with this way I cannot use the history by pressing "up" key etc..