0
votes

Iam trying to define a ISR for a UART interrupt on the esp32, generally, my Programm should just send out and array of bytes from the transmit-buffer(tx-FIFO), do an interrupt as soon as the transmit-buffer is empty and start another output of the same array from the transmit-buffer.

Currenty I cant find how to assign a specific ISR(which I can then define myself) to the UART_TX_DONE_INT interrupt, which indicates that the transmit buffer is empty.

A main reason for my stuck is because i dont get the Idea of what an interrupt handle / handler is, in the way this guy http://zerothelement21.blogspot.com/2018/05/esp32-uart-interrupt-handling.html describes it.

Expectation: I can define an interrupt, which is triggered when the tx_FIFO is empty and that I can define the ISR of this interrupt myself.

1

1 Answers

0
votes

An interrupt handler or an interrupt service routine (ISR) is simply a function/routine that is called by the hardware whenever an interrupt happens, in your case when the UART TX FIFO falls below a certain point the UART will assert the appropriate interrupt flag, which then tells the interrupt controller to “halt” the CPU and then call the appropriate ISR. So the general flow would be to create the interrupt handler as a function, where you would fill the FIFO again, register the function as an interrupt service routine, then enable the interrupt and start TX.

Fortunately in the case of ESP32, Espressif has set up a few convenience functions in their SDK to help with interrupt handling, see this section in the programming guide. The TL;DR is that you need to configure the interrupt by calling uart_intr_config(), register your own handler (simply any C function will do) with uart_isr_register then enable the interrupt with uart_enable_tx_intr().

Edited to add: have you considered that you may not need to write a custom ISR to accomplish what you want? Check out uart_write_bytes() which copies data to an intermediate ring buffer and then exits, while an SDK supplied ISR transfers the data to the FIFO for you.