Changing transmission speed on UART1

I’m trying to change transmission speeds back and forth from 57600 to 9600 baud on UART1. I’ve tried calling UartHandler::Init(), changing the config.baudrate, followed by UartHandler::FlushRx() and UartHandler::StartRx(). The receive buffer doesn’t seem to get reset properly; I’m seeing the information that had previously been read at 57600 showing up again when the 9600 baud section of my test code executes, rather than the expected bytes.

I converted the code to DaisyDuino and there it works beautifully - I call Serial.end() then Serial.begin() to change from 576600 to 9600 with reads/writes to a test driver running on an Arduino Mega. Can someone tell me how to do this properly for daisysp? I can post code, if that’s helpful. Thanks.


in arduino I could put the baudrate into the begin statenment:

Another implementation can be found in midi.cpp

UartHandler::Config config;
config.baudrate      = 31250; // <-- baudrate
config.periph        = UartHandler::Config::Peripheral::USART_1;
config.stopbits      = UartHandler::Config::StopBits::BITS_1;
config.parity        = UartHandler::Config::Parity::NONE;
config.mode          = UartHandler::Config::Mode::TX_RX;
config.wordlength    = UartHandler::Config::WordLength::BITS_8;
config.pin_config.rx = {DSY_GPIOB, 7};
config.pin_config.tx = {DSY_GPIOB, 6};
1 Like

Thanks, Marcel. That’s exactly the code I was using. It turns out that adding a delay fixed the problem - clearly some sort of timing issue. I dropped the whole effort for other reasons, so never got more specific information about why I was having a problem or why my fix worked.