Skip to content

Changing UART Baud rate messes up UART #476

Closed
@eroom1966

Description

@eroom1966

Hello,

I think I have a similar issue to #441

If I configure UART2 to run at 57600 baud, I can send data messages and all works well.
However, I need to be able to perform configuration of the end device at 9600 baud,
then flip both sides of the interface into 57600 - I cannot get this to work reliably.

I have a fixed message length of 24 bytes (at 57600 baud), but when I send messages, there is some strange buffering occuring, such that on the serial line, 21 bytes of the message(0) are sent, then there is a pause until the next message(1) is sent, then I have the missing 3 bytes from message(0), followed by the next 21 bytes if message(1) - and so on.

This only occurs IF the baud rate is changed from 9600 to 57600, if I start with a baud rate of 57600, the messages are transmitted as expected. so effectively what I have is the following

void setup() {
Serial2.begin(9600, SERIAL_8N1, gpioX, gpioY);
}

in the functional code, at some point the interface is reconfigured
Serial2.begin(57600, SERIAL_8N1, gpioX, gpioY);

I have tried with various combinations of
Serial2.end(); // causes the program to stop

and adding delays to no avail.

so can anybody provide a snippett of code to show how to reconfigure the BAUD rate of the interface, without introducing the buffering issue described above.

E.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions