home *** CD-ROM | disk | FTP | other *** search
- The 16550A UART
-
- by Randol Tigrett
-
- If your computer includes a 16550A UART, chances are you'll get faster
- throughput during your communications sessions if your software takes
- advantage of it. To experiment with the UART in your machine, you can
- use the DEBUG script shown in Figure 1 to generate a small program
- called FIFO.COM. You simply run FIFO.COM once when you turn on your PC
- and it activates the FIFO buffers in the UART, displaying what type of
- UART you have in your machine, 8250 or 16550 or 16550A.
- We emphasize the word experiment because some communications
- programs, written before the introduction of the 16550A, might lock up
- when the UART activates the previously unused upper bits of the
- Interrupt ID Register. Even if your communications software doesn't
- lock up with the FIFO buffer activated (and most don't) you still
- won't get the full benefit of the FIFO buffer unless the program makes
- use of it.
- Programs not specifically written for the 16550A won't move
- data in large blocks the way more modern programs do, and FIFO.COM
- can't make your communications program recognize the UART or utilize
- its FIFO buffer better. However, activating the buffer with FIFO.COM
- can potentially eliminate problems of overrunning the UART,
- particularly in a PC on the receiving side of a high-throughput file
- transfer. Although it may help in this way, FIFO.COM mainly
- demonstrates how programmers can activate the buffer.
- The NS16550AF UART (Universal Asychronous
- Receiver/Transmitter) contains two 16-byte FIFO (first in, first out)
- buffers. Slower machines, like an 8-MHz AT, using fast modems need
- these buffers, as do faster machines, like a 33-MHz 386, that attempt
- to run other programs in a multitasking mode while using asynchronous
- communications. The interrupts generated by communications sessions
- can have a serious impact on the effectiveness of computers running
- multitasking operations. Programs in other sessions suspend
- processing, displays don't update, and characters typed at the
- keyboard don't register while the CPU services the UART.
- The 16-byte FIFO buffers reduce the interrupt activity of the
- CPU because they can hold more data before generating an interrupt
- requesting a transfer. This makes it easier for slower CPUs to avoid
- dropping characters when they receive a fast stream of data. You can
- set the receive FIFO buffer to receive 1, 4, 8, or 14 characters
- before the UART generates an interrupt.
- If your computer contains a 16550 UART instead of the 16550A
- or AF, be aware that the plain 16550 was flawed and will not work
- correctly if the FIFO buffers are activated. When you buy a new
- computer, make sure the manufacturer either sockets the UART or
- installs the new 16550A UART. If you can install the UART yourself, it
- costs only about $12. The 16550A UART is especially useful for
- communicating with high-speed modems because, with the advent of
- V.32bis modems, you can now enjoy a carrier rate of 14,400 bits per
- second between modems. With V.42bis data compressions of 4 to 1, you
- must set the DTE (Data Terminal Equipment) speed of the RS-232C link
- to 57,600 bps for optimum performance during file transfers. Slower
- PCs cannot handle the high RS-232C DTE speed without the 16550A UART.
- If you want more information on programming the 16550A UART,
- National Semiconductor makes available a book called Data
- Communications: Local Area Networks: UARTs. The book sells for $10 and
- you can call National Semiconductor at 408-721-5000 to ask about its
- availability.
-
- HOW TO GET FIFO.COM
- You can download FIFO.COM from library 2 of PC MagNet's Utilforum/Tips
- forum (type GO PCM:TIPS from PC MagNet or CompuServe to get there) or
- create it using the DOS DEBUG program.
- Assuming DEBUG is available in the C: root directory, redirect
- the following text to DEBUG by typing
-
- c:\debug <fifo.scr
-
- The text below contains comments to illustrate the program's
- operation. Remove all comments enclosed in /* */ before redirecting to
- DEBUG. Note that this program will cause the 16550 UART to work
- improperly by enabling its flawed FIFO buffer.
-
- A
- JMP 0123
- NOP
- AND [BX+DI],DH
- SS:
- XOR AX,3035
- AND [DI+41],DL
- PUSH DX
- PUSH SP
- AND [BX+SI],AH
- AND [BX+SI],AH
- AND AL,20
- CMP [BP+SI],DH
- XOR AX,2030
- PUSH BP
- INC CX
- PUSH DX
- PUSH SP
- AND [BX+SI],AH
- AND [BX+SI],AH
- AND [SI],AH
- MOV DX,03F8 /* PORT ADDRESS - 0040:0000 */
- ADD DX,+02 /* set offset to IIR Register */
- MOV AL,C1 /* set receive buffer to 14 and enable */
- OUT DX,AL /* change the 14 = 0x0C to 1,4,or 8 */
- XOR AX,AX
- IN AL,DX
- PUSH AX
- AND AL,C0 /* set up for 16550A UART */
- CMP AL,C0 /* is it a 16550A ? */
- JNZ 013D /* no */
- LEA DX,[0103] /* yes */
- JMP 0141
- NOP
- LEA DX,[0113] /* print either 16550 or 8250 */
- MOV AH,09
- INT 21
- POP AX
- MOV AH,4C /* show the IIR setup as errorlevel */
- INT 21
- RET
-
- N FIFO.COM
- RCX
- 4B
- W
- Q
-
- Figure 1: DEBUG script to generate FIFO.COM, a program that activates
- the 16550A UART's FIFO buffer and identifies the type of UART in your
- machine.
- ===============================================
- Toad Hall Note:
-
- The above horribleness can be circumvented by using the new FIFO.ASM
- I just produced with a *real* disassembly of FIFO.COM.
-
- And if you want something a wee bit more sophisticated, look at
- UARTTYPE.ASM (with its accompanying UARTTYPE.MSG). It not only activates
- the UART, but specifically identifies just which one it is!
-
- David Kirschbaum
- Toad Hall
- kirsch%maxemail@uunet