Recently, the function printf does not print any data to the console anymore. I did not face this issue before. I’ve read the threads with similar problems on this forum. However, not any solution worked for me. For example, I’ve added a ‘\n’ character at the end of the string, but this didn’t solve the problem.
Any ideas what can fix this problem? Thanks in advance!
The code is shown below. When I run this code, an “empty” character is being printed in the console.
Maybe it is related to a specific hardware or version of the Mbed OS or tools.
So what a version of MbedOS, a board and tools you use?
For me that printf working well on the MbedOS 6.2.1, Nucleo-F429ZI and Online Compiler.
We’re using the Mbed OS 6 version, in combination with Mbed Studio. The microcontroller that we’re using is NUCLEO-F411RE.
I had the same problem with another board and added this code below #include “mbed.h” and it then worked:
// Create a BufferedSerial object to be used by the system
// Check that the USBTX and USBRX are correctly defined in target pinnames files or define yourself
// Insert the baud rate you want to use
static BufferedSerial serial_port(USBTX, USBRX, 115200);
FileHandle *mbed::mbed_override_console(int fd)
thats strange, a printf() should always work. If the baudrate does not match, you can also set it in the mbed_app.json:
The STDIO_UART_TX/RX can be also remapped in the mbed_app.json, but the defaults work for the USB VCOM. Unless you have modified the solder jumpers on the Nucleo, the VCOM can be disconnected.
// STDIO for console print
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
STDIO_UART_TX = PA_2,
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
STDIO_UART_RX = PA_3,
also PA_2 and PA_3 must not be connected to other hardware.
Yeah, I had the same problem. The ST default is 9600,8,N,1 and the mbed studio defaults are 115200,8,N,1 - just change the baud rate drop down for your board’s serial terminal to 9600 and it works fine.