Ceci est une ancienne révision du document !
Port | Description |
---|---|
3F8h/2F8h | Transmit/Receive Buffer (read/write) Baud Rate Divisor LSB if bit 7 of LCR is set (read/write) |
3F9h/2F9h | IER - Interrupt Enable Register (read/write) Baud Rate Divisor MSB if bit 7 of LCR is set (read/write) |
3FAh/2FAh | IIR - Interrupt Identification Register (read only) FCR - 16550 FIFO Control Register (write only) |
3FBh/2FBh | LCR - Line Control Register (read/write) |
3FCh/2FCh | MCR - Modem Control Register (read/write) |
3FDh/2FDh | LSR - Line Status Register (read only) |
3FEh/2FEh | MSR - Modem Status Register (read only) |
3FFh/2FFh | Scratch Pad Register (read/write) |
Port 3F8h | Transmit/Receive Buffer (read/write) Baud Rate Divisor LSB if bit 7 of LCR is set (read/write) |
Port 3F9h | Interrupt Enable Register - IER (read/write) Baud Rate Divisor MSB if bit 7 of LCR is set (read/write) |
bit | Interrupt Enable Register |
---|---|
0 | 1 = enable data available int (and 16550 Timeout) |
1 | 1 = enable THRE interrupt |
2 | 1 = enable lines status interrupt |
3 | 1 = enable modem-status-change interrupt |
4-7 | reserved (zero) |
- 16550 will interrupt if data exists in the FIFO and isn't read within the time it takes to receive four bytes or if no data is received within the time it takes to receive four bytes.
Baud Rate | Baud Rate Divisor | Baud Rate | Baud Rate Divisor |
---|---|---|---|
50 | 900h | 2400 | 30h |
110 | 417h | 3600 | 20h |
150 | 300h | 4800 | 18h |
300 | 180h | 7200 | 10h |
600 | C0h | 9600 | 0Ch |
1200 | 60h | 19200 | 06h |
1800 | 40h | 38400 | 03h |
2000 | 3Ah | 115200 | 01h |
- Baud rate divisors can be calculated by taking the oscillating frequency (1,843,200) and dividing by the quantity of the desired baud rate times the UART clocking factor (16). Use the following formula:
bit | Interrupt ID Register |
---|---|
0 | 1 = no int. pending, 0=int. pending |
1-2 | Interrupt Id bits (see below) |
3 | 16550 1 = timeout int. pending, 0 for 8250/16450 |
4-5 | reserved (zero) |
6-7 | 16550 set to 1 if FIFO queues are enabled |
Bits 21 | Meaning | Priority | To reset |
---|---|---|---|
00 | modem-status-change | lowest | read MSR |
01 | transmit-register-empty | low | read IIR / write THR |
10 | data-available | high | read rec buffer reg |
11 | line-status | highest | read LSR |
bit | 2FA, 3FA FIFO Control Register |
---|---|
0 | 1 = enable clear XMIT and RCVR FIFO queues |
1 | 1 = clear RCVR FIFO |
2 | 1 = clear XMIT FIFO |
3 | 1 = change RXRDY & TXRDY pins from mode 0 to mode 1 |
4-5 | reserved (zero) |
6-7 | trigger level for RCVR FIFO interrupt |
Bits 76 | RCVR FIFO Trigger Level |
---|---|
00 | 1 byte |
01 | 4 bytes |
10 | 8 bytes |
11 | 14 bytes |
bit | 2FB, 3FB Line Control Register |
---|---|
0-1 | word length select bits (see below) |
2 | 0 = 1 stop bit, 1 = 1.5 or 2 (see note) |
3 | 0 = no parity, 1 = parity (PEN) |
4 | 0 = odd parity, 1 = even (EPS) |
5 | 0 = parity disabled, 1 = enabled |
6 | 0 = turn break off, 1 = force spacing break state |
7 | 1 = baud rate divisor (DLAB); 0 = RBR, THR or IER |
Bits 10 | Word length bits |
---|---|
00 | 5 bits per character |
01 | 6 bits per character |
10 | 7 bits per character |
11 | 8 bits per character |
bit | 2FC, 3FC Modem Control Register |
---|---|
0 | 1 = activate DTR |
0 | 1 = activate RTS |
0 | OUT1 |
0 | OUT2 |
0 | 0 = normal, 1 = loop back test |
6-7 | reserved (zero) |
bit | 2FD, 3FD Line Status Register |
---|---|
0 | 1 = data ready |
1 | 1 = overrun error (OE) |
2 | 1 = parity error (PE) |
3 | 1 = framing error (FE) |
4 | 1 = break interrupt (BI) |
5 | 1 = transmitter holding register empty (THRE) |
6 | 1 = transmitter shift register empty (TSRE) |
7 | 1 = 16550 PE/FE/Break in FIFO queue, 0 for 8250 & 16450 |
bit | 2FE, 3FE Modem Status Register |
---|---|
0 | 1 = DCTS Delta CTS (CTS changed) |
1 | 1 = DDSR Delta DSR (DSR changed) |
2 | 1 = RI ring indicator changed |
3 | 1 = DDCD Delta Data Carrier Detect (DCD changed) |
4 | 1 = CTS |
5 | 1 = DSR |
6 | 1 = ring indicator (RI) |
7 | 1 = receive line signal detect |
<WARP round box>
</WRAP>
Programming considerations: - 8250's, 16450's are essentially identical to program - 16550's is pin and software compatible with the 16450 but has an internal FIFO queue that may be enabled/disabled by software - PCs are capable of 38.4Kb, while AT's are capable of 115.2Kb - receiver checks only the first stop bit of each character regardless of the number of stop bits specified - Older 8250 and 16450 UARTs may lose THRE interrupt if the THRE and Receive Data (RD) or the Line Status (LS) interrupts occur simultaneously during a full duplex transmission. RD and LS have higher priority than THRE which causes the lower priority interrupt to be lost. The following are 3 methods used to avoid this problem:
1. Disable/re-enable THRE interrupt via the IER after processing Receive Data & Line Status interrupts.
2. While inside the RD and LS interrupt routines check the LSR THRE bit and set a flag that a THRE interrupt was waiting. 3. Poll the LSR THRE bit instead of using the IRR.
- data loss can occur without overrun or framing errors if the interrupts are serviced too slowly - reserved bits are usually set to zero. Code should NOT rely on this being the case since future enhancement may use these bits - see INT TABLE or IRQ for interrupt assignments - see PORTS for COMx port assignment (3F8,2F8,3E8,2E8,3220…)