4 months, 1 week ago.

printf stalls when there is no serial connection


I have talked to an mBed representative about this issue and was told to post my problem here. The code I am talking about can be found here:

This is firmware made for one of our company's sensors and it's mostly pretty straightforward. We talk to the sensor via I2C using the mBed API and we grab/display the data. This code was meant to be used in a demo that will light up certain LED's based on what our sensor detects, so usually print functions are not necessary as we have other ways of outputting what we detected in this demo.

However, we did also include some print function to do some basic tracking (program start, register writes, data output, etc). What we found was that if we included the print functions but did not connect the microcontroller to something to receive the serial output, the code simply stalls at the print function.

Does anyone have any insight here?

Thanks, PXVY

Comment on this question

1 Answer

4 months, 1 week ago.

Hello Vincent,

There is no definition for the pc serial object at the link you provided. Something like

Serial pc(USBTX, USBRX);

is missing. So it's hard to say which port is used for the serial communication. However, most likely the hardware flow control pins on that port are also connected to the device that does the USB to serial conversion (virtual serial port). I'd suggest to have a look in the user manual of your mbed board to see how to disconnect the flow control lines of that serial port (probabbly some solder bridges should be opened). A very similar issue was reported at

To post an answer, please log in.