UART rarely reads wrong data

trawgz
Posts: 7
Joined: Thu Feb 11, 2021 12:21 pm

UART rarely reads wrong data

Postby trawgz » Thu Apr 22, 2021 2:31 pm

Hi,

I'm using the UART with DMA by accessing the registers directly without using the driver from the sdk. Currently Im testing a RS485 communication at a baudrate of 230400. And there im getting 1 or 2 crc errors in a hour. On the oscilloscope it is all fine. No reason why the ESP32 should read something different. A screenshot is attached which shows the wrong byte. The ESP32 has read the byte 0x65 instead of 0x6D.

Analog Pin 2 is the RX pin on the ESP32. Analog Pin 3 the RS485 signal. Digital pin 3 is also the RX pin on the ESP32.

Do somebody knows the problem?
Attachments
UART-CRC-ERROR-BYTE.png
UART-CRC-ERROR-BYTE.png (34.56 KiB) Viewed 5345 times

trawgz
Posts: 7
Joined: Thu Feb 11, 2021 12:21 pm

Re: UART rarely reads wrong data

Postby trawgz » Mon Jun 14, 2021 9:30 am

That is only happening with WLAN or with Bluetooth. With WLAN there are 1 or 2 errors in a hour and with Bluetooth every 1-2 minutes.
If both WLAN and Bluetooth is turned off, it is running several days without any errors.

Why? And can I prevent this errors, with Bluetooth and WLAN turned on?

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

Re: UART rarely reads wrong data

Postby WiFive » Mon Jun 14, 2021 2:00 pm

You should provide hardware details, idf commit, and an example code to reproduce the problem. You have scope trace at the exact time of the error or scope logs crc errors? Is it always a single bit error?

trawgz
Posts: 7
Joined: Thu Feb 11, 2021 12:21 pm

Re: UART rarely reads wrong data

Postby trawgz » Fri Jun 25, 2021 6:25 am

Hardware: ESP32 Rev3
ESP-IDF: git tag v4.2
The example code that im using is a mix of "bluetooth/nimble/bleprph" and "peripherals/uart/uart_echo_rs485", which is in attachment. You can change the pins in the IDF menuconfig. There are no logs in the example code, because im using my own JTAG-Logging. But you can insert logs when an error occured. Im using an external device which sends RS485 to the ESP32 with a Baudrate of 115200 and Even-Parity and 2 Stop-Bits. You should keep the Parity (doesnt matter if even or odd, to detect errors in frame), but you can change Baudrate and Stop-Bits and it also doesnt matter if the communication is coming from RS485 or from normal UART.

After 5 minutes the stats are saying following (Bluetooth turned on):
Received bytes: 2970022
Errors: 4

Before I have run the same without enabling Bluetooth (ble_main() call) and I have zero errors in more than 30 minutes.

Before I have tested in my own environment and disabled the parity and checked the data via CRC. There I see that there are always Single-Bit-Errors.

The Scope represents the Byte on the Bus which is correct (0x6D), but the ESP32 reads in this moment 0x65.

And it need to be some sort of hardware errors, because Im using an own UART driver with DMA access and the same problem is also occuring with the esp-idf UART driver.
Attachments
uart_bluetooth.zip
(31.62 KiB) Downloaded 356 times

trawgz
Posts: 7
Joined: Thu Feb 11, 2021 12:21 pm

Re: UART rarely reads wrong data

Postby trawgz » Mon Jul 05, 2021 1:33 pm

Problem fixed. Bluetooth Modem Sleep was the problem. Zero errors in several days, when I disabled it.

irfan93
Posts: 4
Joined: Thu Jul 07, 2022 2:05 pm

Re: UART rarely reads wrong data

Postby irfan93 » Mon Oct 03, 2022 1:40 pm

trawgz wrote:
Mon Jul 05, 2021 1:33 pm
Problem fixed. Bluetooth Modem Sleep was the problem. Zero errors in several days, when I disabled it.
Hello trawgz,

I am facing something similar where my bytes gets distorted. Can you explain what the Bluetooth Modem Sleep was doing that was affecting the bytes coming into ESP32 and how removing it solved?

Thanks,
Irfan.

Who is online

Users browsing this forum: No registered users and 24 guests