Electronic – What are the use cases of FIFO Half-Full and Three-Quarter Full interrupts in Receive FIFO of a UART

fifomicrocontroller

I am implementing a protocol decoder which receives bytes through UART of a microcontroller. The ISR takes bytes from the UART peripheral and puts it in a ring buffer. The main loop reads from the ring buffer and runs a state machine to decode it.

The UART internally has a 32-byte receive FIFO, and provides interrupts when this FIFO is quarter-full, half-full, three-quarter full and completely full.

  • How should I determine which of these interrupts should trigger my ISR?
  • What is the trade-off involved?

Note – The protocol involves packets of 32-byte (fixed length), send every 10ms.

Best Answer

If you know the exact length of the received message, then you should use an interrupt on received characters number.

The FIFO half-full, quarter,..-full interrupts are used whenever you recive a streaming data. Example: when it is half-full you process the received data (half) in the meantime the buffer shouldn't overrun. When you leave the ISR and do some other things the buffer is still filling, again you wait for interrupt when it is half full.

With bidirectional communication like master-slave, this kind of interrupts are useless.