ESP32 UART interrupt every character

2.2k views Asked by At

Is there a way to generate an uart interrupt on an ESP32 as soon as a single character has been received?

I know you can generate an interrupt when the whole message has been received, or on a specific pattern, buffer overflows, errors, etc., but I am looking for a (simple) way to this on a per character basis.

1

There are 1 answers

0
Tarmo On

Assuming you're working with ESP IDF, you can configure the UART interrupts to trigger from a RX threshold of a single byte quite easily. Omitting all error handling:

uart_intr_config_t uintr_cfg = {.rxfifo_full_thresh = 1};
uart_intr_config(UART_NUM_x, &uintr_cfg);
uart_enable_rx_intr(UART_NUM_x);