Exploring printf on Cortex-M | Interrupt

The C printf function is a staple of embedded development. It’s a simple way to get logs or debug statements off the system and into a terminal on the host. This article explores the various ways to get printf on Cortex-M microcontrollers.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/printf-on-embedded
1 Like

If you are using C++ and in search for a type-safe, extensible alternative to printf which doesn’t take up to much flash memory, take a look at the library emio which provides a python/fmt like format/print/scan functionality.

While executing prinf() in semi-hosting mode with DAP-Debugger (buffered mode) program execution halts for approximately 40 ms when ‘\n’ symbol is sent. ISR code is not processed.
In Disassembly window __iar_sh_stdout executes CDPLT instruction - a call to co-processor 0.
What is the mechanism of tranfering debug data to IDE? Does DAP Debugger halts cpu while sending debug data?