6 years, 4 months ago.


I want to get printf to work with mbed for debugging. If there is a better way to debug, please let me know. Otherwise, I don't get printf decent to work. I think it's the communciationsettings, but I don't get it to work. All I get it garbage.

I use a macbook pro and a nucleo STM32F411 with the Terminal application from OSX.

Does anyone know what can be wrong?


Number of stop bits mismatched? or receiver is not ready to receive in time?

posted by Waldemar Dworakowski 20 Jul 2015

1 Answer

6 years, 4 months ago.

This looks like a classical baud rate mismatch problem. I believe that using plain printf (without instantiating a serial object) defaults to baudrate of 9600 (8N1) on the TX/RX (PA2/PA3) pins (USART2). How did you configure the GNU Screen terminal program?

Try something like:

'screen /dev/tty.ACM0 9600'

Be sure to replace 'tty.ACM0' with the approriate serial port name of the Nucleo

Have a look here for more info on how to use screen:



I personally prefer to use minicom & cutecom (on Linux)

I've tried it as you write: screen /dev/tty.usbmodem1413 9600 but it does not solve the problem.

posted by Twan Dieltjes 21 Jul 2015

Seems to be fixed. I had a statement as: pc.printf("Output: " + i); This caused the problem. I changed it to: pc.printf("Output %d \n",i);

Programmer error :)

posted by Twan Dieltjes 21 Jul 2015