Page 1 of 1
UART rarely reads wrong data
Posted: Thu Apr 22, 2021 2:31 pm
by trawgz
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?
Re: UART rarely reads wrong data
Posted: Mon Jun 14, 2021 9:30 am
by trawgz
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?
Re: UART rarely reads wrong data
Posted: Mon Jun 14, 2021 2:00 pm
by WiFive
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?
Re: UART rarely reads wrong data
Posted: Fri Jun 25, 2021 6:25 am
by trawgz
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.
Re: UART rarely reads wrong data
Posted: Mon Jul 05, 2021 1:33 pm
by trawgz
Problem fixed. Bluetooth Modem Sleep was the problem. Zero errors in several days, when I disabled it.
Re: UART rarely reads wrong data
Posted: Mon Oct 03, 2022 1:40 pm
by irfan93
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.