Page 1 of 1

UART 2Baud rates on single UART

Posted: Wed Apr 19, 2017 3:50 pm
by Tino123
Hi everyone ;) ,

I'm struggling with the UART communication. I need to change the baud rate on a single UART to implement a specific protocol. So my goal is to have two baud rates right after each other at a transmission with a minimum of change delay.
I tried to do that on low level, so I used something like the following code:

Code: Select all

//Setup
uartBegin(...);

//Loop
while(1){
uart_set_baudrate(BAUDRATE1);
uartWrite(Data1)
uart_set_baudrate(BAUDRATE2);
uartWrite(Data2)
}
The code has a good behaviour till I add the 2nd "uart_set_baudrate()" function. The result is a time drift somewhere (this depends on the length of the sent data) in Data2 .
So I think the problem consists of timing problems.

Has anyone an idea how to fix that or had the same issue

Thanks!

Re: UART 2Baud rates on single UART

Posted: Wed Apr 19, 2017 11:04 pm
by ESP_igrr
Depending on how your uartWrite function is implemented, you may need to add a call to uart_wait_tx_done before changing the baud rate.

If this doesn't help, can you capture the output using a logic analyzer?


http://esp-idf.readthedocs.io/en/latest ... TickType_t