Hello,
Use a USBSerial interface to emulate a serial port over USB rather than an UART port.
The “programming” USB connector is connected to the Mbed UART’s D1
, D0
pins over an on-board USB-to-UART converter. The USBTX
is an alias name of the D1
pin and the USBRX
of the D0
pin. Hence, when you create two objects like:
static BufferedSerial pc(USBTX, USBRX);
static BufferedSerial uart(D1, D0);
then both the pc
and uart
objects actually represent the same UART interface. That’s why both print to the same virtual serial port (serial terminal) on the PC (using the USB driver of the on-board USB-to-UART converter installed to the PC during the Mbed board setup procedure). In addition, the global printf
function (and the similar debug
function) also prints to the same UART (aka “Serial console” or stdout
). However, it is possible to remap the global printf
(and bebug
) function to other UART. For more details read here. If you need a serial connection using streams then this library can be handy too.
Best regards, Zoltan