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

Using ITM retarget with Keil Software Packs

I recently found out that in Keil 5 I can select different IO retarget modes. So I went and gave it a try.

I go to "Manage Run-Time Enviroment" -> Compiler -> I/O and select STDIN equal ITM. After that, retarget_io.c appears in the project window.

I briefly read it and found out several interesting things:

- It compiles (which is good).

- There is a definition of ITM_SendChar function, which is already defined in core_cm4.h.

- If I add printf call in my program, code size bloates from 436 bytes (empty main) to 3538 bytes (one printf call in main).

- That printf call doesn't do anything in simulation, debug (printf) window is empty.

I used to implement I/O retargeting roughly like this:

int fputc(int c, FILE *f)
{
  return ITM_SendChar(c);
}
void _ttywrch(int ch)
{
  ITM_SendChar(ch);
}

- If I implement retarget like this, printf call makes code size just 704 bytes.
- It actually works in simulator.

So my question is: am I doing something wrong here?

I'm using Keil 5.23 with ARMCC compiler 5.06 update 4 (build 422).