Hi,
I'm developing some UART code for latest ESP32C5 using dev/v5.5.0.
I'm working with uarts at 115k2, 8, no parity, 1 stop bit, hw flowcontrol disable, and default clock.
Since we can receive different size frames (from 6 to 2048 bytes) and we have also different header bytes we have applied an strategy to use uart_set_rx_timeout for catching the frames, put this frames in a buffer and analyze them out of the uart event callback
Timeout has been set to 3 ms.
excerpt of even callback implementation:
for (;;)
{
//Waiting for UART event.
if (xQueueReceive(uartlp_queue, (void *)&event_lp, (TickType_t)portMAX_DELAY))
{
bzero(ucTempData_lp, UART_LP_RD_BUFF_SIZE);
switch (event_lp.type)
{
case UART_DATA: //Event of UART receving data
{
static uint8_t ucFrameBuffer[UART_LP_RD_BUFF_SIZE];
static uint16_t ucFrameLength = 0;
int16_t siNumBytesRead = uart_read_bytes(LP_UART_NUM_0, ucTempData_lp, event_lp.size, portMAX_DELAY);
// Accumulate data in the frame buffer
if (siNumBytesRead > 0)
{
if (ucFrameLength + siNumBytesRead <= UART_LP_RD_BUFF_SIZE)
{
memcpy(ucFrameBuffer + ucFrameLength, ucTempData_lp, siNumBytesRead);
ucFrameLength += siNumBytesRead;
}
else
{
// Frame buffer overflow, discarding data
ucFrameLength = 0; // Reset frame length on overflow
}
}
// Check if the event was caused by a timeout, then frame is completed
if (event_lp.timeout_flag)
{
// Send the complete frame of data
BLEDriver_TransmitBuffer(ucFrameBuffer,ucFrameLength);
ucFrameLength = 0; // Reset frame length after processing
}
break;
}
case UART_FIFO_OVF:
As I said, code is running fine for ALMOST all frame sizes (6 to 2048 bytes) but we have detected that if size of received frame is UART_FULL_THRESH_DEFAULT (120) or
LP_UART_FULL_THRESH_DEFAULT (10) the UART_DATA data event is just called once and not when timeout is reached, so that frames are not properly handled.
Could you please take a look at this specific scenario ? Note that I have replicate this in ESP32C6 and ESP32S3 not just only in ESP32c5
Thanks
UART TimeOut Issue
-
tazdevil72
- Posts: 1
- Joined: Tue Mar 18, 2025 7:00 am
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- ESP32-S31
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- ESP32-S31 中文讨论版
- 喵伴 中文讨论版
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: PetalBot and 1 guest
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.
Information
Espressif ESP32 ... Available now!