Issues with printf function

Issues with printf function

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.

 

Timing Diagram For Printing “Hello World!” Using printf() Through A UART At 9600 Baud – Image courtesy of EDN

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.

Performance Of The Non-blocking Version - Images courtesy of EDN
Performance Of The Non-blocking Version – Images courtesy of EDN

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

Please follow and like us:
Pin Share

Embedded Hardware Engineer interested in open hardware and was born in the same year as Linux. Yahya is the editor-in-chief of Atadiat and believes in the importance of sharing free, practical, spam-free and high quality written content with others. His experience with Embedded Systems includes developing firmware with bare-metal C and Arduino, designing PCB&schematic and content creation.

view all posts by yahya
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
Get new posts by email:
Get new posts by email:

Join 97,426 other subscribers

Archives