SLAU646F September 2015 – June 2020
The printf() function is commonly used to assist with debugging, however its behavior in MSP430-GCC is dependent on the debugging software being used.
When debugging within CCS, printf() output is shown in the CIO console.
When debugging with GDB and the GDB Agent, printf() is silently ignored. This is because the default implementation relies on the debugger understanding the TI C I/O protocol, which is currently unimplemented in GDB.
The default implementation can be overridden by defining the write() system call in your application. The write() function is called with the finalized string, ready to be printed, and must handle the process of outputting the string. The prototype for write() is:
int write (int fd, const char *buf, int len);
fd
is the file
descriptor, which for printf will always be STDOUT.buf
contains a
pointer to the formatted string.len
is the
number of bytes from buf
that should be written.