What is the UART TX interrupt for?

The TX interrupt is mainly for longer datagrams. You can initiate the transfer for a buffer of known length (bytecount). Now you can push your buffer pointer as often as there are bytes to send, when the TX interrupt occurs. This ensures the "as quick as possible" transfer of your buffer, without the need to poll any "TransferComplete"-Flag/Statusbit.


The main goal of the TX interrupt (really an END OF TX) is to send the content of a buffer (multiple bytes) automatically. When implemented in a proper way:

  1. Enable the TX interrupt.
  2. The user code starts transmission by sending only the first byte in the buffer.
  3. At the end of TX (of the first byte), an interrupt will be generated.
  4. In the TX ISR (Interrupt Service Routine), the code must send the next byte in the buffer and update the buffer index.
  5. At the end of this transmission, a new interrupt occurs, and so on, until the entire content of buffer is sent "automatically".
  6. Disable the TX interrupt.

The exact behavior depends on the microcontroller. That is a general description.


Some UARTS have an internal buffer that is larger than one, the 16xxx series for one.

The procedure here was

  1. Set a transmit window mask, for example to 4 remaining.
  2. fill buffer positions until the UART said full or no more data need to be send
  3. do other stuff
  4. when only 4 buffer positions are left unsend, set TX interrupt
  5. wait for the interrupt to be serviced
  6. if more data needs to be send go to 2.

This decreases the CPU load by offloading some processing to the UART thus enabling slower CPU's to keep up and service other task instead of getting interrupted all the time.