UART ISR handaling in ESP IDF 5.0 +

teja.godavarthi
Posts: 2
Joined: Fri Nov 04, 2022 10:24 am

UART ISR handaling in ESP IDF 5.0 +

Postby teja.godavarthi » Fri Mar 14, 2025 9:04 am

I am working with an ESP32-C6 and need to handle UART RX interrupts byte-by-byte without creating a FreeRTOS task. I found that uart_isr_register() is deprecated in ESP-IDF 5.0+, so what is alternate approach or any example code

Requirements
Use interrupt-based UART RX handling (without polling or tasks).
Handle incoming bytes individually inside the ISR.
Manually clear interrupt flags to avoid re-triggering

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: UART ISR handaling in ESP IDF 5.0 +

Postby MicroController » Mon Mar 17, 2025 8:22 am

without creating a FreeRTOS task.
Any specific reason for this?

teja.godavarthi
Posts: 2
Joined: Fri Nov 04, 2022 10:24 am

Re: UART ISR handaling in ESP IDF 5.0 +

Postby teja.godavarthi » Tue Jul 08, 2025 6:19 am

Yes, when around 100 bytes of data are received from an external source, the task waits until all bytes are received. This delay is causing a timeout in my application. If I had an ISR (Interrupt Service Routine) that triggers on each byte received, it would help handle the data more efficiently and avoid the timeout.

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: UART ISR handaling in ESP IDF 5.0 +

Postby MicroController » Thu Jul 10, 2025 10:27 pm

You can change this behavior by
1) setting a low "RX full threshold", e.g. via uart_set_rx_full_threshold(), and either
2a) using the "event-based" programming model of the UART driver (where the driver sends you "events" via a FreeRTOS queue), or
2b) reading any data via uart_read_bytes() as it becomes available, see viewtopic.php?p=147877#p147896

Who is online

Users browsing this forum: Bytespider, Perplexity-User and 4 guests