UART RX FULL interrupt implementation

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

UART RX FULL interrupt implementation

Postby imdaad » Sat Feb 19, 2022 3:25 am

hello All,
I need to implement an interrupt when the Rx FIFO buffer is filled with a specific number of characters. However, I find it difficult to program it. As you can see the API reference says how should we do it, but the conventional isr handers are missing in these APIs. can someone send me a code snippet, indicating how to achieve this? I am rather stuck without. thank you
Attachments
esp.png
esp.png (186.3 KiB) Viewed 6788 times

john_bul
Posts: 2
Joined: Wed Jan 09, 2019 9:09 am

Re: UART RX FULL interrupt implementation

Postby john_bul » Mon Feb 21, 2022 9:45 am

Same problem.
From docs/en/migration-guides/peripherals.rst :
- :cpp:member:`uart_isr_register` and :cpp:member:`uart_isr_free` have been removed as the UART interrupt handling is closely related to the driver implementation.

How to specify my own interrupt handler?

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: UART RX FULL interrupt implementation

Postby ESP_Sprite » Mon Feb 21, 2022 10:32 am

@imdaad: You're not supposed to, the interrupt is handled in the driver. You'd set the threshold of the RX buffer in the UART configuration, then (possibly in a separate task) you do a (blocking) read from the uart.

@john: You can still use the generic ESP-IDF interrupt allocator to allocate your 'raw' UART interrupt.

User avatar
WardMas
Posts: 75
Joined: Fri Jun 19, 2020 9:09 am

Re: UART RX FULL interrupt implementation

Postby WardMas » Mon Feb 21, 2022 5:57 pm

Hi,
AS far as I know, first of all you need to set the threshold you want and activate that specific interrupt in https://www.espressif.com/sites/default ... f#page=347 UART_INT_RAW_REG resister, which is the first bit in your case.

Code: Select all

uart_intr_config_t UART_ISR_Config = 
{
	.intr_enable_mask = 0b00000001,
	.rxfifo_full_thresh = 50			//Change this threshold to suit your code 		 
}
then you will pass the ISR config pointer to

Code: Select all

uart_intr_config(uart_port_t uart_num, const uart_intr_config_t *intr_conf);
For ESP32 UART driver installation, I advice you to follow the following UART event example:
https://github.com/espressif/esp-idf/tr ... art_events
You can always visit my YouTube channel for embedded systems related tutorials
https://youtube.com/user/wardzx1

Who is online

Users browsing this forum: Google [Bot] and 418 guests