0% found this document useful (0 votes)
63 views14 pages

Understanding Serial Ports and COM Interfaces

This document describes the serial port and its characteristics. It defines the serial port as a digital communication interface that transmits data in series, one bit at a time. It explains the architecture of the serial port, including the need for two wires for bidirectional communication and the use of start and stop bits. It also covers technical features such as the DB-9 connector, transmission speed, and common uses. Finally, it includes programming examples in assembly language for serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views14 pages

Understanding Serial Ports and COM Interfaces

This document describes the serial port and its characteristics. It defines the serial port as a digital communication interface that transmits data in series, one bit at a time. It explains the architecture of the serial port, including the need for two wires for bidirectional communication and the use of start and stop bits. It also covers technical features such as the DB-9 connector, transmission speed, and common uses. Finally, it includes programming examples in assembly language for serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HIGHER TECHNOLOGICAL INSTITUTE OF SAN ANDRÉS TUXTLA

COMPUTER SYSTEMS ENGINEERING

Ana Francisca Lule Rangel

6th SEMESTER / Group B

CONCEPTION MEZO MAZABA.

SAN ANDRÉS TUXTLA VER.

January - June 2017


Content
Definition of porto ...................................................................................................................... 1
Definition of serial port........................................................................................................... 1
Diagram (architecture of the serial port)................................................................................ 1
Technical characteristicss ............................................................................................................... 3
Characteristics of the serial COM port.................................................................................. 3
Electrical terminals of the serial port. ............................................................................... 4
Physical variant of the serial port.............................................................................................. 4
Transmission speed of the serial port COM .............................................................. 5
Specific uses of the COM serial port.............................................................................. 5
Applicationss .................................................................................................................................... 5
Example of programming in assemblyr ............................................................................ 5
Serial communication in assembly language................................................................. 5
Example 1...................................................................................................................................... 8
Example 2.9
Bibliography..................................................................................................................................... 12
Definition of port
In computing, a port is a generic term for an interface through which
different types of data can be sent and received. This interface can be physical type, or
it can be at the software level (for example, the ports that allow data transmission between
different computers) in which case it often uses the term logical port.

Definition of serial port


A serial port or serial interface is a digital data communication interface,
frequently used by computers and peripherals, where information is transmitted bit by bit
bit, sending one bit at a time; in contrast to the parallel port that sends several bits
simultaneously.

The comparison between series and parallel transmission can be explained using an analogy.
with the roads: a traditional one-lane road (on a two-way road) for
each sense corresponds to the serial transmission, and a highway with several lanes for
sense corresponds to parallel transmission, with vehicles being the bits that circulate through the
cable.

Diagram (architecture of the serial port)


Serial ports (also called RS-232, after the name of the standard to which they refer)
they were the first interfaces that allowed devices to exchange information with the
external world. The serial term refers to data sent through a single thread: the bits are
they send one after the other (see the section on data transmission for the modes
of transmission).

1
Originally, serial ports could only send data, not receive, so they were developed.
bidirectional ports (which are the ones found in current equipment). Therefore, the
Bidirectional serial ports require two wires for communication to take place. The
serial communication is carried out asynchronously, meaning that a signal is not necessary (or
Synchronization clock: data can be sent at random intervals. In turn, the peripheral
It must be able to distinguish the characters (a character has a length of 8 bits) among the bit sequence.
that is being sent. This is the reason why in this type of transmission, each character is
finds preceded by a START bit and followed by a STOP bit. These bits of
controls necessary for serial transmission waste 20% of the bandwidth (every 10 bits
sent, 8 are used to encrypt the character and 2 for reception). The serial ports, for
generally, they are integrated into the motherboard, which is why the connectors found at the back
from the case and are connected to the motherboard via a cable, they can be used
to connect an external element. Generally, serial connectors have 9 or 25 pins and
they have the following shape (DB9 and DB25 connectors respectively):

A PC usually has between one and four serial ports. Asynchronous serial port Through
this type of port communication is established using an asynchronous transmission protocol.
In this case, an initial signal is first sent before the first bit of each byte, character or
encoded word. Once the corresponding code is sent, a signal is immediately sent.
stop after each encoded word. The start signal is used to prepare for the
reception mechanism or receiver, the arrival and registration of a symbol, while the signal of
Stop serves to predispose the reception mechanism to take a break and prepare.
for the reception of the new symbol. The typical start-stop transmission is the one used in the
transmission of ASCII codes through the RS-232 port, such as the one established in the
operations with teletypewriters.

The RS-232 serial port (also known as COM) is of the asynchronous type, using single wiring.
from 3 threads to 25 and connects computers or microcontrollers to all types of peripherals,
from terminals to printers and modems passing through mice. The interface between the RS-232 and the
The microprocessor is generally implemented using the UART 8250 chip (8 and 16 bit computers,
PC XT) or the 16550 (IBM Personal Computer/AT and later). The original RS-232 had a connector

2
DB-25 type, however most of those pins were not used, so IBM standardized with
its IBM Personal System/2 range the use of the DB-9 connector (already introduced in the AT) that was used,

mainly on computers. However, except for the mouse, the rest of the peripherals
the DB-25 was usually presented The RS-422 standard, similar to RS-232, is a standard used in the field
modern serial ports One of the drawbacks of the early serial ports was their slowness
compared to parallel ports - we're talking about 19.2 kbits per second - however, with
As time goes by, a multitude of high-speed serial ports are appearing that make them very
interesting as they present the advantages of less wiring and solve the problem of the
decrease in speed using greater shielding, and cheaper, using the pair technique
braided. Therefore, the RS-232 port, and even many parallel ports, are being replaced.
being replaced by new serial ports such as USB, FireWire, or Serial ATA. Types of
simplex serial communication In this case, the sender and the receiver are perfectly defined and
communication is unidirectional. This type of communication is usually used in networks
of broadcasting, where receivers do not need to send any type of data to the transmitter. Duplex,
half duplex or semi-duplex In this case, both ends of the communication system fulfill
transmitter and receiver functions, and the data moves in both directions but not in a uniform manner
simultaneous. This type of communication is commonly used in the interaction between terminals and
a central computer. Full Duplex The system is similar to duplex, but the data moves
in both directions simultaneously. For it to be possible, both emitters have different
transmission frequencies or two separate communication paths, while the
semi-duplex communication usually requires only one. For data exchange between
computers this type of communications are more efficient than semi-transmissions
[Link].

Technical characteristics
Characteristics of the serial COM port
In the field of commercial electronics, it is referred to as a DB9 connector ('D-
subminiature type B, 9 pin"), this is D-subminiature type B, with 9 pins.
It was mainly used for connecting the mouse, some old types of
scanners and currently for devices such as PDAs ("Personal Digital Assistant") or
digital personal assistants.
Each port allows connecting only 1 device.
To connect and disconnect the devices, as well as for the computer to
to recognize it correctly, it is necessary to turn off and restart the computer.

3
Electrical terminals of the serial port.
The serial port has 9 pin-type contacts; the electrical lines and their description are shown.
basic.

Diagram of the serial port COM lines

1. DCD (Detects the carrier)


2. RxD (Receives data)
3. TxD (Transmit data)
4. DTR (Data Terminal Ready)
5. SG (Earth)
6. DSR (Data Set Ready)
7. RTS (Request to send)
8. CTS (Available to send)
9. RI (Indicates call)

Physical variant of the serial port


Some external devices and even computers can have a port.
different serial than the common 9 pins. This serial port consists of 25 pins, is male type and is used
often accompanied by an adapter to be used with 9-pin connectors.

25-pin female serial connector of the device

Adapter for the 25-pin serial port to 9-pin

4
Transmission speed of the COM serial port
The way to measure the transmission speed of the serial port is in Kilobytes/second (KB/s):

Port Speed in (KiloBytes/second)

Serial COM 112 KB/s

Specific uses of the COM serial port


The main use assigned to it was to connect the mouse, and even scanners, but
with the market release of the USB port, it stopped being used for this purpose. A current use is for
connect some types of PDAs, electronic organizers, direct connections between computers
Laplink, electronic devices for academic practices and data collectors.

Applications
Advanced Serial Port Terminal is specifically designed to establish a connection with a
serial port and send/receive data on that port. Our serial port terminal application is
an essential utility as it can send and receive various data (ASCII strings, binary, octal
in hexadecimal), redirect the input/output data flow to a specific file, verify and
solve modem configuration problems without overloading the serial port.

Example of assembly programming


Serial communication in assembly language.
In assembly language, you can call interrupt 14H of the ROM-BIOS to configure,
read, write or simply to check the status of the port; each of these four options
it is a service of interruption, and they are selected through the AH register. Figure 1 shows the
values that the AH record must contain to invoke each of the services. In all cases,
the DX register must contain the serial port number; the first of them, COM1 is specified
as 00h.

5
To configure or initialize the serial port, it will be enough to use service 00 of the interrupt.
placing the equivalent values of the parameters in register AL, as can be seen in
figure 2. With this method, it is possible to obtain transmission frequencies ranging from 110
up to 9600 baud.

6
To send a data through the serial port, it will be enough to place the value 01 in the AH register.
corresponding to this service and in the AL record the data to be sent, invoking again the
interruption 14H. The reading of a data that has arrived at the port is achieved with service 02, which
returns the data in register AL. The reading of the port state is obtained through the service
03 of this same interruption, and it returns in the AX register the state of the port, which will contain the
bits shown in figure 3.

For example, we can use assembly language to set the serial port to 1200.
baud rate, without parity bit, without stop bit, and 8 bits, executing the following program:

move ah,0 service 00 of INT 14h: initialize port


mov a1, 83; configuration: 1200 baud, no parity,
1 stop bit, 8 bits of data
mov dx,00 ;Select COM1 port
int 14 BIOS interruption
mov ah,4c ; service 4ch of INT 21h: terminate
int 21 service interruption of the DOS

This program (where all amounts are expressed in hexadecimal) can become
executable using some of the assemblers for PC, or using the DEBUG command of
DOS.
Another way to select the parameters of communication and achieve it is through the
modification and consultation of the records corresponding to the integrated circuit that manages the

7
serial communication: the UART 8250 or similar. As is known, this integrated circuit can be
managed like a port, in which it is possible to write or read its states.

Communication with the parallel port in assembly language.


In assembly language, a data can be read from the port using the IN instruction or write a
given in the port with the instruction OU, in both cases the register AL must actively participate
in the instruction, either as a source (in write operations) or destination (in operations of
reading) of the data, as in the following cases:

out DX, AL ; sends the content of register AL to port DX


in AL,DX ;brings to register AL the content of the port DX

Another requirement is that the number of the port over which the data transfer will take place
it must be marked by the DX register, except in cases where the port number
is less than 255 (FFh), in which case the instruction that reads or writes can point directly to
port.

Example 1.
Connection between two computers using a serial cable, one computer is left listening.
through the hyperterminal (leaving the default configuration) and the other computer is
where the program runs.

pile segment stack "STACK"


how many ends

data segment
data ends

code segment
assume cs:code,ds:data,ss:pila
start:
mov AH,00; INITIALIZE PORT
mov AL, 11100111b ;default port parameters
mov DX,00 ;com1 port
INT 14h

MOV AH,01; send data through the port

8
MOV AL, 52; character to be sent
INT 14h

The 4CH function of the 21HF inte returns control to the operating system
MOV AH, 4CH
INT 21H
code ends
end start

Example 2.
The following is a code used to establish serial communication between a computer and
a microcontroller from the brand Motorola with the reference HC908GP32.
The code consists of sending characters from the keyboard of a computer connected via the port.
serial to the microcontroller, which in turn has a 7-segment display connected through its PTB port
segments in the following way:
7-segment display —————— Microcontroller —————— PC
The microcontroller receives characters from the PC if they are numbers from 0 to 9 then
shows on the display the letter E indicating error.
The following is the code that should be burned into the microcontroller explained step by step.

FLS EQU $8000; it will start at position 8000 in memory


RST EQU $FFFE
CONFIG1 EQUALS $1F
PTB EQU $01; the Port B is started
DDRB EQU $05; the DRRB is configured
SCDR EQU $0018
TC EQU $06
SCISR EQU $0016
SCRF EQU $05
CONT EQU $60; a pointer is created at position 60 named CONT
DATE EQU $61; a pointer is created at position 61 named DATO
VAR EQU $62; a pointer is created at position 62 named VAR
SCC1 EQU $0013
SCC2 EQU $0014
SCBR EQU $0019
ORG FLS; is configured as the starting point of the FLS program

9
MAIN: BSET 0, CONFIG1; disables the COP
The entire system is configured to establish communication.
MOVE #$03, SCBR
BSET 6, SCC1
BSET 2, SCC2
BSET 3, SCC2
MOV #$FF, DDRB; configure the entire Port B as output
START: MOV $00, PTB; turn off the entire port
LDHX #MSG; load the message 'ENTER A NUMBER'
TX: LDA, X
Compare #$FF

BEQ PRINT
BRCLR TC, SCISR,*; Wait for a data to be sent to the micro
STA SCDR
AIX #$01
BRA TX
BSR DELAY
BRCLR SCRF, SCISR,*
LDA SCDR
CMP #$39
BGT ERROR
CMP #$30
BLO ERROR
SUB #$30
THIS DATE
LDHX #TABLE; load the corresponding number into the table
TXA
ADD DATA
TAX
LDA, X
EOR #$80
STA PTB; send the corresponding number to the display
BSR DELAY
BRA START
ERROR:
MOV #$F9, PTB; sends the letter E to the display

BSR DELAY; goes to the subroutine to wait for a time

10
GO TO START; return to the beginning of the program

generate a timer routine with the variable VAR


DELAY: MOVE #$00, CONT
FOLLOW: CLR VAR

LOOP: NO
NOP
NOP
NOP
NOP
DEC VAR
BNE LAZO
DEC CONT
BNE CONTINUES

RTS
; envía un mensaje al computador “INGRESE UN NUMERO”
MSG: DB"ENTER A NUMBER",$FF
TABLE: DB 3F; table of numbers from 0 to 9
DB 06
DB 5B
DB 4F
DB 66
DB 6D
DB 7D
DB 07
DB 7F
DB 67
ORG RST
DW MAIN; return to the beginning of the program

END; end the program

11
Bibliography
[Link]

[Link]
the-hc908gp32-microcontroller/

[Link]

[Link]

[Link]

12

You might also like