The Effect of UART FIFO Sizes on Serial Application PerformanceHardware: Serial
Problem: How Do UART FIFO Sizes Affect Serial Application Performance? Solution: What is a UART and what are its FIFOs? A UART (Universal Asynchronous Receiver/Transmitter) is the device which ultimately controls the receive and transmit (read and write) operations performed by a given serial port. In particular, UARTs have dedicated memory in the form of a FIFO structure (first in first out; a queue structure) for each the receive and transmit operations. The purpose of the FIFO structures is to hold data either received from the serial port or to be written to the serial port. Moreover, most UARTs allow the size of the FIFO used to be specified in software (in the Device Manager for Windows OS's; directions for changing these FIFO sizes are contained in the KB linked below entitled: Why Do I Get Buffer Overflows with My Serial Port When Using VISA with Flow Control?). That is, there is a maximum size which is limited by the total amount of memory on the UART, but you can specifically define the size to be used. Sometimes not every size less than or equal to the maximum can be selected, for example, many RS-232 ports have UARTs which have a maximum FIFO receive buffer size of 14, but only allow 1, 4, 8, and 14 as possible sizes for use. However, the transmit buffer size of many UARTs can often take every integer value from 1 to 16. How do the FIFOs affect performance? The size of the FIFO buffers determine when the UART interrupts the CPU in order to transfer data between the FIFO and CPU memory (RAM, where applications running on the CPU have access to the data). Therefore, the size of the FIFOs can affect latencies in writing to and read from the serial port, usually on the order of milliseconds, as well as overall performance of a given application. For example, if you set the receive buffer to 1, the UART will interrupt the processor to transfer a single byte to CPU memory whenever a byte is received. While this will make a given byte available in RAM as soon as possible after arriving at the port, if data is continuously being received at the port, this will cause many interrupts. As a result, more CPU processing is dedicated to those interrupts which can decrease overall performance if other programs are running. Thus, if latencies on the order of a few milliseconds are tolerable for serial operations, it is often beneficial for overall performance to use a larger receive FIFO size. Note that an interrupt will occur regularly in order to ensure that even if the receive FIFO size is, say, 14 bytes that you can receive and have access to data even if only, say, 4 bytes were ever received. Similarly, the transmit FIFO size dictates the number of bytes that can be transferred from RAM to the transmit FIFO at a time. Therefore, if the transmit FIFO size is larger you can reduce latency in transferring large amounts of data by sending more data on each interrupt. There is another important factor which contributes to performance at the application level when writes to the serial port (and from RAM to the transmit FIFO in particular), which is discussed in the KB linked below entitled: The Affect of Asynchronous vs Synchronous Settings for VISA and GPIB Write and Read Functions. Related Links: KnowledgeBase 3D9B8E4B: The Effect of Asynchronous vs Synchronous VISA Write and Read Functions KnowledgeBase 18TFOGTI: 8 Port Serial Boards and UART Programming Questions KnowledgeBase 3BE87GW3: Why Do I Get Buffer Overflows with My Serial Port When Using VISA with Flow Control? Attachments:
Report Date: 09/10/2004 Last Updated: 12/22/2008 Document ID: 3D9B7L4B |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
