Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 6 months 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:
2 Answers
6 years, 5 months 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.
6 years, 6 months 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