Download presentation
Presentation is loading. Please wait.
Published byAbraham Higgins Modified over 6 years ago
1
CS-401 Computer Architecture & Assembly Language Programming
Lecture-38 Serial Port Programming
2
Serial Port
3
Serial Port Connector 1 – Carrier Detect (CD) 2 – Received Data (RD)
3 – Transmitted Data (TD) 4 – Data Terminal Ready (DTR) 5 – Signal Ground 6 – Data Set Ready (DSR) 7 – Request to Send (RTS) 8 – Clear to Send (CTS) 9 – Ring Indicator (RI)
4
Frame Format data bits (5-8) Start bit (1) parity bit (1) Stop bits
(1-2)
5
Connection Diagram TD RD Ground TD RD Ground
6
Transmission setting
7
int 0x14 Serial Initialize Port AH = 0x00 AL = port parameters
DX = port number (0x00 – 0x03) Return AH = line status Al = modem status
8
Port Parameters - AL baud rate 000-110 001-150 010-300 011-600
7 6 5 4 3 2 1 baud rate parity 00-N 10-N 01-O 11-E data bits 00-5 01-6 10-7 11-8 stop bits 0-1 1-2
9
Write Character to Port
int 0x14 Serial Write Character to Port AH = 0x01 AL = character DX = port number (0x00 – 0x03) Return AH (bit 7)= set on error AH (bits 0-6)= port status
10
Read Character from Port
int 0x14 Serial Read Character from Port AH = 0x02 AL = character DX = port number (0x00 – 0x03) Return AH = line status AL = received character (AH bit 7 clear)
11
int 0x14 Serial Get Port Status AH = 0x03 AL = character
DX = port number (0x00 – 0x03) Return AH = line status AL = modem status
12
Line Status 7 6 5 4 3 2 1 0 rx ready time out tx shift register empty
time out rx ready tx shift register empty over run tx holding register empty parity error break detect framing error
13
Serial Ports IO ports
14
Serial Port I/O Ports COM1: 0x03F8-0x03FF COM2: 0x02F8-0x02FF
15
Serial Port I/O Ports Port 0x3F8/0x2F8 Transmit Holding Register (THR)
Receiver Buffer Register (RBR)
16
Serial Port I/O Ports Port 0x3F9/0x2F9 Interrupt Enable Register (IER)
Bit 0 = Received Data Available Bit 1 = Transmitter Holding Register Empty
17
Interrupt Identification Register
Serial Port I/O Ports Port 0x3FA/0x2FA Interrupt Identification Register Bit 0 = Interrupt Pending Status (0) Interrupt Pending (1) Interrupt Not Pending Bit 1-3 = Pending Interrupt Source (001) THR Empty (010) Received a Character
18
Serial Port I/O Ports Port 0x3FB/0x2FB Line Control Register (LCR)
DLAB data bits set break enable stop bit parity
19
Serial Port I/O Ports Port 0x3FD/0x2FD Line Status Register (LCR)
reserved data ready tx shift register empty over run tx holding register empty parity error break detect framing error
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.