UART 2Baud rates on single UART

Tino123
Posts: 1
Joined: Wed Apr 19, 2017 3:30 pm

UART 2Baud rates on single UART

Postby Tino123 » Wed Apr 19, 2017 3:50 pm

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!

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: UART 2Baud rates on single UART

Postby ESP_igrr » Wed Apr 19, 2017 11:04 pm

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

Who is online

Users browsing this forum: Majestic-12 [Bot], MicroController and 103 guests