5

I have a small project that I added my own custom debug functions to so I could have some extra functionality. They have been working great, and use the following method to send the data:

while(*bp)
  ITM_SendChar(*bp++);

I finally got around to switching over all the printf statements to use my own function and all the output just stopped. A little playing around and I figured out as long as I have one single printf function compiled in, no matter where, ITM_SendChar works right out the gate.

It would seem there is some functionality compiled in when printf is used in the project that allows ITM_SendChar to work.

It is not a huge deal but I am fairly curious as to why this is. Is there perhaps another way to initialize the ITM (Instrumentation Trace Macrocell) system without having to stick in a dummy printf?

artless noise
  • 21,212
  • 6
  • 68
  • 105
RobC
  • 502
  • 4
  • 17
  • 1
    After building your project, you're supposed to have a map file created. You can build the project without `printf`, rename the map file, rebuild it again with a "dummy" `printf` somewhere, and compare the current map file with the previous map file. In particular, search for the symbols `ITM_SendChar` and `printf`, and see if there are any differences around those areas. Your theory of "some functionality compiled in when `printf` is used" sounds weird, but if there is an "additional functionality" then you should be able to see it as part of the differences between the two files. – barak manos Nov 04 '14 at 09:10
  • I also noticed that there are some subtle details controlling whether you see ITM output or not. I recommend to check out the lovely ITM howto on the atollic blog, which also points to external ITM settings in the trace adapter and such. – HelpingHand May 31 '20 at 21:20

1 Answers1

1

I came across the same problem and I tried everything with correct configuration of the ITM Registers. But I couldn't figure it out.

My solution to not use memory intense printf, is to use putchar:

while(*bp)
  putchar(*bp++);

It even works, when I just have one putchar somewhere in the code which outputs one character and then output the other things with ITM_SendChar()

I assume the IAR automatically adds some configuration function as soon as the putchar function is included.

A. Bieri
  • 13
  • 3