Uart reading issue

flobue
Posts: 1
Joined: Fri Dec 08, 2017 1:14 pm

Uart reading issue

Postby flobue » Mon Dec 11, 2017 6:16 am

Hello,
I'm having a problem with reading from the UART from the ESP-WROOM32.
The problem is, that the recieved data does not come in the right order, after the rx buffer(ringbuffer?) is full, for the first time. I send a continious stream, whith a 10 Bit pattern (0x02, counter(0x00-0xFF), 0x00, 0x02, 0x04, 0x06, 0x10, 0x11, 0x12, 0x13). The recieved data looks something like this, after the rx buffer is full(Note: I used new lines to gourp parts of the stream, which come in the correct order):

02df0002040610111213, 02e00002040610111213, 02e10002040610111213, 02e20002040610111213, 02e30002040610111213, 02e40002040610111213, 02e50002040610111213,
0002040610111213,
02da0002040610111213,
02db00020406101110111213,
02e90002040610111213, 02ea0002040610111213, 02eb0002040610111213, 02ec0002040610111213, 02ed0002040610111213, 02ee0002040610111213, 02ef0002040610111213, 02f00002040610111213, 02f10002040610111213,
0002040610111213,
02e60002040610111213, 02e700020406101110111213,
02f50002040610111213, 02f60002040610111213, 02f70002040610111213, 02f80002040610111213, 02f90002040610111213, 02fa0002040610111213, 02fb0002040610111213, 02fc0002040610111213, 02fd0002040610111213

The odd thing is, that if I flush the rx buffer (with uart_flush) the error still occures. Infact if I did read less than, the rx buffer holds, and i call uart_flush, the error will occure, even if the rx bufferwas not a single time full.

The code I use is pretty simple and mostly copied from the examples:

Code: Select all

const uint32_t buffer_len = 256;
static const uart_port_t UART_PORT_NR = UART_NUM_1; //tried with UART1 and UART2

Init()
{
        uart_config_t uart_config = uart_config_t
       {
              .baud_rate = 5000000,           //5MHz
              .data_bits = UART_DATA_8_BITS,
              .parity = UART_PARITY_EVEN,
              .stop_bits = UART_STOP_BITS_1,
              .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
              .rx_flow_ctrl_thresh = 40,
              .use_ref_tick = false,
       };
       //Configure UART1 parameters
       uart_param_config(UART_PORT_NR, &uart_config);
       //Install UART driver, no queue, no TX buffer, buffer_len * 4 for debug -> delay reading error
       uart_driver_install(UART_PORT_NR, buffer_len * 4, 0, 0, NULL, 0);
       //Set UART pins
       uart_set_pin(UART_PORT_NR, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
}
Read(uint8_t* buffer)
{
       return uart_read_bytes(UART_PORT_NR, &buffer[0], buffer_len, 5000);
}
I have found a few other reports of the same/similar problems, but without a soulution, which worked for me:
viewtopic.php?t=2804
Sorry for the bad english and probalbly stupid question.
Regards

ferreira
Posts: 4
Joined: Sat Dec 30, 2017 7:20 pm

Re: Uart reading issue

Postby ferreira » Sat Dec 30, 2017 7:28 pm

I have the same problem with a UART.
After the buffer full up, all data is wrong, with or without a flush.
If I change the program to never leave the buffer full, everything works perfectly.
Did you find a solution about?

llewellyn
Posts: 33
Joined: Fri May 05, 2017 8:22 am

Re: Uart reading issue

Postby llewellyn » Sun Dec 31, 2017 9:58 am

Hi,

I am facing the same problem. As long as I don't let the buffer get full it works perfectly.
I haven't found any solution for that yet.

Regards

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Uart reading issue

Postby WiFive » Sun Dec 31, 2017 10:59 am


ferreira
Posts: 4
Joined: Sat Dec 30, 2017 7:20 pm

Re: Uart reading issue

Postby ferreira » Mon Jan 15, 2018 3:46 pm

Thank you WiFive.
I applied this fix but it continues with the same problem.

ferreira
Posts: 4
Joined: Sat Dec 30, 2017 7:20 pm

Re: Uart reading issue

Postby ferreira » Mon Jan 15, 2018 4:03 pm

Hi llewellyn,

Did you solve UART issue?
Thanks in advance.

llewellyn
Posts: 33
Joined: Fri May 05, 2017 8:22 am

Re: Uart reading issue

Postby llewellyn » Tue Jan 16, 2018 7:14 am

Hi,

A day ago there was an update in the IDF to fix this issue. I haven't got around to testing it yet.

https://github.com/espressif/esp-idf/co ... fb61431339

ferreira
Posts: 4
Joined: Sat Dec 30, 2017 7:20 pm

Re: Uart reading issue

Postby ferreira » Fri Jan 19, 2018 7:56 pm

Yes, I tested this update today and it seems that it solved the problem.
Thank you very much.

burkulesomesh43
Posts: 132
Joined: Tue Aug 14, 2018 6:21 am
Location: India

Re: Uart reading issue

Postby burkulesomesh43 » Wed Mar 20, 2019 8:01 am

llewellyn wrote:
Tue Jan 16, 2018 7:14 am
Hi,

A day ago there was an update in the IDF to fix this issue. I haven't got around to testing it yet.

https://github.com/espressif/esp-idf/co ... fb61431339
I am using esp idf v3.1.3 in which fixed this issue.
but still getting same problem.
please help me out for solving this issue.
--
Somesh Burkule

Who is online

Users browsing this forum: Baidu [Spider] and 260 guests