The C library function printf() is one of the common used functions in embedded systems world to debug the code in real time over a serial connection. Using the printf() over serial is under debate and may not be optimal for embedded systems and that’s what Jacob Beningo over EDN tries to demonstrate.
The first problem with using printf() is the need to bring a standard C library into the software which consumes a lot from RAM and ROM/Flash which are limited in size. The second problem is during the execution time of printf() where system becomes blocked until all characters have been transmitted.
Jacob addressed some solutions and alternatives. One of them was developing a non blocking version of printf() that uses an interrupt service routine to handle transmission of buffer content.
Another solution is to use SWD (Single Wire Debugger) interface, a 2-pin debug port for ARM MCUs, which minimizes software overhead where an internal buffer gets filled and the debug hardware automatically handles transmission to the debug probe. You can read more about SWD in ARM website.
Via: EDN