I am programming on an arm microprocessor and am trying to debug using print statements via UART. I do not want to add stdlibs
just for debugging. Is there a way to
Since printing out information through a serial port in an embedded system modifies the main program's timing, the best solution I've found is to send a small message encoded in 2 bytes (sometimes 1 byte works fine), and then using a program in the PC to decode those messages and provide the necessary information, which can include statistics and everything you may need. This way, I'm adding just a little bit of overhead to the main program, and letting the PC do the hard work to process the messages. Maybe something like this:
1 byte message: bits 7:4 = module ID, bits 3:0 = debug info.
2 bytes message: bits 15:12 = module ID, bits 11:8 = debug info, bits 7:0 = data.
Then, in the PC software, you have to declare a table with the messages that map to a given module ID/debug info pair, and use them to be printed on the screen.
Maybe it's not as flexible as the pseudo-printf function, since you need a fixed set of messages in the PC to decode, but it doesn't add too much overhead, as I mentioned before.
Hope it helps.
Fernando