10 years, 5 months ago.

Changing mbed USB Serial Speed When Using RTOS?

Since the mbed RTOS causes problems with using the Serial class, declaring the usual "Serial pc(USBTX, USBRX);" doesn't work. Is it possible to speed up the mbed USB serial connection targeted by stdio's "print" commands? 9600 baud is rather slow for an RTOS and I would like to use 115200. I would prefer not to have to play around with the mbed-rtos source, if possible...

Question relating to:

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard. cmsis, rtos, RTX

2 Answers

10 years, 5 months ago.

Thomas,

When using RTOS, I use RawSerial pc(USBTX, USBRX); Works well for me both in TX and RX modes.

...kevin

Accepted Answer

RawSerial pc(USBTX, USBRX); pc.baud(115200);

Will correctly set the stdio baud. Thanks!

posted by Thomas Murphy 03 Jun 2014
10 years, 5 months ago.

Hello Thomas,

the object is defined as serial_t stdio_uart. The method which allows you to change the baudrate is

void serial_baud(serial_t *obj, int baudrate);

It should allow you to change a baudrate, using mbed HAL (be aware that mbed HAL is subject to change :-) ). Does this what you want to achieve?

How come Serial pc(..) does not work with RTOS?

Regards,
0xc0170

It seems that having a declaration of a Serial pc(tx,rx) in a RTOS application causes something to stall. Using the TCPEchoClient from https://mbed.org/handbook/Socket fails to communicate over serial or ethernet when I create a Serial object either at initialization or after initializing the ethernet.

posted by Thomas Murphy 03 Jun 2014