Report
4 weeks ago.

Serial Port Baud rate defaults to 9600, inspite of setting a higher baud rate with MBED OS 5.9.

After creating a serial object and setting it a baud rate doesn't seem to take effect on mbed OS 5.9. It defaults to 9600 baud rate. This works perfectly well in 5.8.5 build. Not sure what has changed since MBED OS 5.9 on NRF52_DK.

This is the code in the main function that creates the serial object and sets the baud rate.

serial code

 m_pc = new Serial(USBTX, USBRX);
 m_pc->baud(115200);
 m_pc->set_flow_control(SerialBase::Disabled);

this is a method in the log file that is called to log data and can be viewed via the serial com port on the computer.

logger

void Logger::printMessage(int level, const char* format, ...) {
    if (printable(level)) {
        va_list argptr;
        va_start(argptr, format);
        vprintf(format, argptr);
        va_end(argptr);
    }
}

Question relating to:

The nRF52 Development Kit is a single-board development kit for Bluetooth Smart, ANT and 2.4GHz proprietary applications using the nRF52 Series SoC. This kit supports both development for nRF52832 SoCs.
Comment on this question

2 Answers

2 weeks ago.

Unfortunately, I have the same issues as Ajay.

my code

Serial serial(P0_20, P0_23); // pins determined by schematics of custom board.
serial.baud(57600);
// print over Segger Jlink 
LOG("Baudrate: %d \r\n", NRF_UART0->BAUDRATE);

Output with mbed-5.8.6:
"Baudrate: 15462400"
15462400 corresponds to 57600 baud according to datasheet.

Output with mbed-5.9.1:
"Baudrate: 2576384"corresponds to 9600, the default.

4 weeks ago.

Hi Ajay,

We're not seeing any issues with setting the baud rate for the nRF52_DK under Mbed v5.9 or the master branch. We've tested with 115200 baud, 2400 baud and the default 9600.

We aren't familiar with the Logger class you are using.

Could you try printing with m_pc->printf() instead?

Regards,

Ralph, Team Mbed

I use printf too and in each case it has a series of 0's in the output with mbed ver 5.9 and then when i change the baud rate to 9600, the actual text shows up. This works perfectly well in the previous versions of mbed with almost exactly the same source code.

Thanks, Ajay

posted by Ajay Kashyap 21 Jun 2018

To post an answer, please log in.