Enabling flow control on UART at lower baud rates causes transmission errors

htech1991
Posts: 2
Joined: Wed Oct 20, 2021 9:41 pm

Enabling flow control on UART at lower baud rates causes transmission errors

Postby htech1991 » Wed Oct 20, 2021 10:12 pm

I have a successful running UART configured as RS-485 half-duplex.

When the driver is installed, the initial configuration is 115200 N81 with no flow control enabled. I can communicate both ways successfully.

I then enable xon/xoff software flow control with:

Code: Select all

uart_set_sw_flow_ctrl(uartPortNum, true, 8, (UART_FIFO_LEN - 8));
Afterwards, I am still able to communicate both ways successfully.

However, if I modify the initial configured baud rate to be something lower, such as such as 9600, or at runtime, change the baud rate the lower value using

Code: Select all

uart_set_baudrate(uartPortNum, 9600);
At the lower baud rate, I run into problems when the flow control is enabled.

Initially, I can communicate just fine at the lower baud rate. But after I enable xon/xoff software flow control in the same manner as above, the characters transmitted are not correct. On the other end, it seems to be receiving mostly FF and FE characters, even though I'm transmitting normal, printable characters. And yes, I check the return value to uart_set_sw_flow_ctrl() and it is successful.

After trying many things, I found that, while in this bad state, I change the baud rate back to 115200, transmit at least one character, then change the baud rate back to 9600, it brings it out of the bad state and I can transmit characters successfully again. Of course, this isn't an acceptable workaround, but I'm hoping that someone with more knowledge in these things may be helped by knowing that.

I've tried other, lower baud rates and I see similar, but not exact results. For instance, at 57600, about every other characters is "bad", while the remaining are successfully transmitted.

I am able to change at runtime any other UART parameters, such as parity, stop bits, and data bits (and baud rate) without any trouble. It is just this one flow control setting that is causing havoc.

I appreciate any help.

htech1991
Posts: 2
Joined: Wed Oct 20, 2021 9:41 pm

Re: Enabling flow control on UART at lower baud rates causes transmission errors

Postby htech1991 » Thu Oct 21, 2021 12:56 pm

I neglected to also mention, that, once in the "bad" state caused by enabling flow control, then disabling flow control does not restore good communication. The only steps that I could find that restores good communication is to change the baud rate to 115200, send a character, then change the baud rate back to 9600, in that order.

Who is online

Users browsing this forum: No registered users and 176 guests