4 years, 2 months ago.

printf

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?

/media/uploads/twdi/screen_shot_2015-07-19_at_23.40.37.png

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

posted by Waldemar Dworakowski 20 Jul 2015
Comment on this question

1 Answer

4 years, 2 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:

http://www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-screen-set-baud-rate/

https://wiki.archlinux.org/index.php/GNU_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

You need to log in to post a question