0% found this document useful (0 votes)
8 views10 pages

Lect 24

hhhh

Uploaded by

Schwarz Chimunhu
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)
8 views10 pages

Lect 24

hhhh

Uploaded by

Schwarz Chimunhu
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
You are on page 1/ 10

Overview

COMP2121: Microprocessors and


Interfacing
• The Components of a Asynchronous Communication
System
Lecture 24: Serial Input/Output (I)
• Standards for the Serial I/O Interface
• RS232-C and Other Standards
http://www.cse.unsw.edu.au/~cs2121
Lecturer: Hui Wu
Session 1, 2006
COMP2121: Microprocessors and 2
Interfacing

The Components of a Asynchronous


Why Serial I/O? Communication System

Problems with Parallel I/O:


Data From Source Data From Source
• Needs a wire for each bit. 8 8
• When the source and destination are more than a few
feet the parallel cable can be bulky and expensive. Transmit Data Received Data
Buffer Buffer
• Susceptible to reflections and induced noise for long
distance communication.
Tclock Serial Data Serial In/Parallel Out Rclock
Parallel In/Serial Out
Serial I/O provides a solution to these problems. Shift Register Shift Register

TRANSMITTER RECEIVER

COMP2121: Microprocessors and 3 COMP2121: Microprocessors and 4


Interfacing Interfacing
The Components of a Asynchronous The Components of a Asynchronous
Communication System (Cont.) Communication System (Cont.)

At the communication source: At the communication destination:


• The parallel interface transfers data from the source to • Rclock shifts each bit received into the serial in/parallel
the transmit data buffer. out shift register.
• These data are shifted into the parallel in/serial out shift • After all data bits have been shifted, they are transferred
register and Tclock shifts the data out to the receiver. to the received data buffer.
• The data in the received data buffer are transferred to the
input operation via the parallel interface.

COMP2121: Microprocessors and 5 COMP2121: Microprocessors and 6


Interfacing Interfacing

UART UART (Cont.)

• The device that implements both transmitter and receiver


in a single integrated circuit is called a UART (Universal
Tclock1 Rclock2
Asynchronous Receiver/Transmitter). Transmitter Receiver
Data Bus Data Bus
• UART is the basis for most serial communication
hardware. Rclock1 Tclock2
Receiver Transmitter
• Details of UART will be covered in the next lecture.

UART UART

COMP2121: Microprocessors and 7 COMP2121: Microprocessors and 8


Interfacing Interfacing
Design Considerations of the Data Encoding and Transmission
Serial Communication System
• Several codes used for the alphanumeric information.
• The most common is ASCII (American Standard Code
• How are data to be encoded? for Information Interchange), using 7 bits to encode 96
• If the data are sent in serial, which bit is set first? printable characters and 32 control characters.
• How the receiver synchronised with the transmitter? • Two choices for the order of data transmission: least
• What is the data rate? significant bit first or most significant bit first.
• How are the electrical signals for logic values defined? • USRT uses least significant first order.
• How does the system provide for handshaking? • Data are transmitted asynchronously. Therefore,
synchronisation between transmitter and receiver is
required.
• UART provides a way to synchronise the receiver shift
register with the transmitter shift register.
COMP2121: Microprocessors and 9 10
Interfacing

Data Encoding and Transmission (Cont.) Data Encoding and Transmission (Cont.)

• Data are encapsulated in two other bits called start bit • Typical bits in data transmission:
and stop bit.
 Start bit: When the transmitter has data to send, it first changes
• Mark and space: the logic one and zero levels are called the line from the mark to the space level for one bit time. This
mark and space. synchronises the receiver with transmitter. When the receiver
 When the transmitter is not sending anything, it holds the line at detects the start bit, it knows to start clocking in the serial data
bits.
mark level, also called idle level.
 Data bits: Almost any number of data bits can be sent between
the start and stop bits. Typically, between 5 and 8 bits are sued.
Least Significant Optional Stop
 Parity bit: The parity bit, used to detect errors in the data, is
Bit Parity Bit Bit
added to the data to make the total number of ones odd (odd
Mark parity) or even (even parity).
Space  Stop bit: The stop bit is added at the end of data bits. It gives
one bit-time between successive characters. Some systems
Start 5 to 8
require more than one stop bit.
Bit Data Bits
11 12
Data Transmission Rate Standards for the Serial I/O Interface

• The rate at which bits are transmitted is called baud rate. Interface standards are needed to allow different
• It is given in bits per second. manufacturers’ equipment to be interconnected and must
• Standard data rates – Baud: define the following elements:
110, 150, 300, 600, 900, 1200, 2400, 4800, 9600, 14400, • Handshaking signals.
19200, 38400, 57800 • Direction of signal flow.
• Types of communication devices.
• Connectors and interface mechanical considerations.
• Electrical signal levels.

COMP2121: Microprocessors and 13 COMP2121: Microprocessors and 14


Interfacing Interfacing

Standards for the Serial I/O Interface Communication System Types


(Cont.)
Three ways that the data can be sent in serial
The existing standards include RS-232-C, RS-422, RS-423
communication system:
and RS-485.
• RS-232-C standard is used in most serial interface. • Simplex system:
 Data are sent in one direction only, say, to a serial printer.
• If the signals must be transmitted farther than 50 feet or
 If the computer does not send data faster than the printer can
greater than 20 Kbits/second, another electrical interface
accept it, no handshaking signals are required.
standard such as RS-422, RS-423 or RS-485 should be
 Two signal wires are needed for this system.
chosen.
• For RS-422, RS-423 and RS-485, handshaking,
direction of signal flow, and the types of communication
Computer Printer
devices are based on the RS-232-C standard.

COMP2121: Microprocessors and 15 COMP2121: Microprocessors and 16


Interfacing Interfacing
Communication System Types (Cont.) Communication System Types (Cont.)

• Full-duplex (FDX) system: • Half-duplex (HDX) system:


 Data are transmitted in two directions.  Data are transmitted in two directions with only one pair of
 It is called four-wire system, although only two signal wires signal lines.
and a common ground are sufficient.  Additional hardware and handshaking signals must be added to
an HDX system.

Terminal Computer Computer Computer

COMP2121: Microprocessors and 17 COMP2121: Microprocessors and 18


Interfacing Interfacing

Half-Duplex Handshaking Signals


Half-Duplex Handshaking Signals (Cont.)
Figure 1 shows a half-duplex system with additional interface
• The interface blocks have three roles:
circuitry and handshaking signals defined for the RS-232-C
 They give a full-duplex channel between themselves and the terminal
interface standard. or computer.
 They decide whether they or their opposite interface is sending or
Full-Duplex Half-Duplex Full-Duplex receiving data
Interface Interface Interface  They use and control the request to send (RTS) and clear to send
(CTS) handshaking signals.
Terminal Interface Interface  The RTS signal is asserted by the terminal or computer when data are to
Computer
be sent.
RTS RTS RTS RTS  When the interface finds that the other system is not sending data, it
asserts CTS signal. The sending station must wait until it is clear to send
CTS CTS CTS CTS
before transmitting.
• Half duplex systems are not often used these days, although
Figure 1 Half-duplex system with
the RTS/CTS handshaking signals have been retained to
handshaking 19 20
control the flow of data.
Data Terminal Equipment and Data Data Terminal Equipment and Data
Communication Equipment Communication Equipment (Cont.)
• Half-duplex modems are no longer used because modem have
• The blocks labelled “Interface” in Figure 1 are, in practice, been developed to allow full-duplex data transmission over a
modems, and the two-wire half-duplex line is a telephone line. telephone line.
• Modems are called data communication equipment (DCE). • A full-duplex system has two types of modems, called
• The terminals or the computers to which modems are attached originate and answer modems, and two sets of tones.
to are called data terminal equipment (DTE).
Originate and answer modem tone definitions for Bell 212A
• A modem is a modulator/demodulator.
Originate modem Direction Answer modem
 It converts logic levels into tones to be sent over a telephone line.
Modulator tones Demodulator
 At the other end of the telephone line, a demodulator converts the 1070 Hz — Space →
tones back to logic levels.
1270 Hz — Mark
 In a half-duplex system, a single set of tones are defined, one for space Demodulator Modulator tones
and one for mark.
← 2025 Hz — Space
21 2225 Hz — Mark 22

Modem Handshaking Signals Modem Handshaking Signals (Cont.)


• Data Terminal Ready (DTR)
 This signal comes from the DTE and inform the modem that it is
• Ring Indicator (RI) ready to operate.
 The telephone company transmits a special tone that rings the  This is usually just an indication that the power is turned on in the
phone. The modem can detect this and asserts the RI signal. terminal but could be controlled by a computer.
 The terminal or computer can use RI to start some special  An intelligent answer modem can use it to answer a call
process such as notifying the user that the other end is calling or automatically only when the computer or terminal is ready.
to answer the telephone in an answer modem.
• Data Carrier Detect (DCD)
• Data Set Ready (DSR)  DCD is asserted when the carrier, or tone defined for a mark, is
 This signal tells the DTE that the modem (also called data set) being generated by the modem on the other end.
has established a connection over the telephone line to the far  It was originally used in half-duplex systems.
end.
 When one end wanted to transmit, it first asserted the RTS line. The
modem then checked the DCD bit. If it found it asserted, it knew the
other end was sending. When DCD was deasserted, CTS was
asserted, allowing transmission from the requesting terminal.
COMP2121: Microprocessors and 23 24
Interfacing
Modem Handshaking Signals (Cont.) RS-232-C Signal Definitions
DE9 DB25 Signal Purpose
DCE
DTE 1 PG Protective ground: this is actually the shield
TxD TxD in a shielded cable. It is designed to be
connected to the equipment frame and may
RxD RxD be connected to external grounds.
Gnd Gnd Telephone Line 3 2 TxD Transmitted data: Sourced by DTE and
Terminal received by DCE. Data terminal equipment
RI RI Modem cannot send unless RTS, CTS, DSR and
or
DTR are asserted.
Computer DSR DSR
2 3 RxD Received data: Received by DTE, sourced
DTR DTR by DCE.
7 4 RTS Request to send: Sourced by DTE, received
DCD DCD by DCE. RTS is asserted by the DTE when
it wants to send data. The DCE responds by
asserting CTS.
COMP2121: Microprocessors and 25 26
Interfacing

RS-232-C Signal Definitions (Cont.) RS-232-C Signal Definitions (Cont.)


DE9 DB25 Signal Purpose DE9 DB25 Signal Purpose

8 5 CTS Clear to send: Sourced by DCE, received 1 8 DCD Data carrier detect: Sourced by DCE,
by DTE. CTS must be asserted before the received by DTE. Indicates that a DCE has
DTE can transmit data. detected the carrier on the telephone line.
Originally it was used in half-duplex
6 6 DSR Data set ready: Sourced by DCE and
systems but can be used in full-duplex
received by DTE. Indicates that the DCE
systems, too.
has made a connection on the telephone
line and is ready to receive data from the 4 20 DTR Data terminal ready: Sourced by DTE and
terminal. The DTE must see this asserted received by DCE. Indicates that DTE is
before it can transmit data. ready to send or receive data.
5 7 SG Signal ground: Ground reference for this
9 22 RI Ring indicator: Sourced by DCE and
signal is separate from pin 1, protective
received by DTE. Indicates that a ringing
ground.
signal is detected.
COMP2121: Microprocessors and 27 COMP2121: Microprocessors and 28
Interfacing Interfacing
RS-232-C Interconnections RS-232-C Interconnections (Cont.)
DE9 DB25 DB25 DE9
• When two serial ports are connected, the data rate, the number
of data bits, whether parity is used, the type of parity, and the DTE DTE DCE DCE
number of stop bits must be set properly and identically on TxD 3 2 2 3 TxD
each UART. RxD 2 3 3 2 RxD
• Proper cables must be used. There are three kinds of cables SG 5 7 7 5 SG
from which to choose, depending on the types of devices to be RTS 7 4 4 7 RTS
interconnected.
CTS 8 5 5 8 CTS
 The full DTE – DCE cable.
 The DTE – DTE null modem cable.
DCD 1 8 8 1 DCD
 The minimal DTE – DCE cable. DSR 6 6 6 6 DSR
DTR 4 20 20 4 DTR

Full DTE – DCE cable


COMP2121: Microprocessors and 29 30
Interfacing

RS-232-C Interconnections (Cont.) RS-232-C Interconnections (Cont.)


DE9 DB25 DB25 DE9 DE9 DB25 DB25 DE9
DTE DTE DCE DCE DTE DTE DCE DCE
TxD 3 2 2 3 TxD TxD 3 2 2 3 TxD
RxD 2 3 3 2 RxD RxD 2 3 3 2 RxD
SG 5 7 7 5 SG SG 5 7 7 5 SG
RTS 7 4 4 7 RTS RTS 7 4 4 7 RTS
CTS 8 5 5 8 CTS CTS 8 5 5 8 CTS
DCD 1 8 8 1 DCD DCD 1 8 8 1 DCD
DSR 6 6 6 6 DSR DSR 6 6 6 6 DSR
DTR 4 20 20 4 DTR DTR 4 20 20 4 DTR

DTE – DTE null modem cable Minimal three-wire cable


31 32
RS-232-C Interconnections (Cont.) RS-232-C Interface
DE9 DB25 DB25 DE9 RS-232-C Logic levels:
DTE DTE DCE DCE
Mark -25 to –3 volts
TxD 3 2 2 3 TxD
RxD 2 3 3 2 RxD Space +25 to +3 volts
SG 5 7 7 5 SG
RTS 7 4 4 7 RTS RS-232-C
CTS 8 5 5 8 CTS TTL Logic
D
Logic levels
TTL Logic
levels R
DCD 1 8 8 1 DCD levels
DSR 6 6 6 6 DSR
DTR 4 20 20 4 DTR

Minimal null modem cable


33 COMP2121: Microprocessors and 34
Interfacing

RS-423 Standard RS-422 Standard


• Also a single ended system. • RS-422 line drivers and receivers operates with differential
• Allows longer distance and higher data rates than RS-232-C. amplifier.
• Allows a driver to broadcast data to 10 receivers.  These drivers eliminate much of the common-mode noise experienced
with long transmission lines, thus allowing the longer distances and
higher data rates.
D R

D R
Up to 10
receivers
Up to 10
R receivers

RS-423 Interface 35 RS-422 Interface 36


RS-485 Standard Line Lengths and Data Rates
• Similar to RS-422 in that it uses differential line drivers and
receivers. RS-423 line length and data rate RS-422 line length and data rate
• Unlike RS-422, RS-485 provides for multiple drivers and Line length (ft) Data rate Line length (ft) Data rate
receivers in a bussed environment. 30 100 Kbits/s 40 10 Mbits/s
 Up to 32 drivers/receivers pairs can be used together. 300 10 Kbits/s 400 1 Mbits/s
4000 1 Kbits/s 4000 100 Kbits/s

D
R RS-485 line length and data rate
Up to 32 Up to 32
Line length (ft) Data rate
drivers receivers
40 10 Mbits/s
D 400 1 Mbits/
R
4000 100 Kbits/s

RS-485 Interface 37 38

Summary of Standards Reading


Specification RS-232-C RS-423 RS-422 RS-485
Receiver input ±3 to ±15V ±200mV to ±12V ±200mV to ±200mV to
voltage ±7V -7 to +12V 1. Chapter 10: Serial Input/Output. Microcontrollers
Driver output signal ±5 to ±15V ±3.6 to ±6V ±2 to ±5V ±1.5 to ±5V and Microcomputers by Fredrick M. Cady.
Maximum data rate 20 Kb/s 100 Kb/s 10 Mb/s 10 Mb/s
Maximum cable 50 ft 4000 ft 4000 ft 4000 ft 2. http://www.camiresearch.com/Data_Com_Basics/RS
length 232_standard.html.
Driver source 3-7 KΩ 450 Ω min 100 Ω 54Ω
3. http://www.beyondlogic.org/serial/serial.htm.
Impedance
Receiver input 3 KΩ 4 KΩ min 4 K Ω min 12 KΩ minimum
resistance
Mode Singled-ended Singled-ended Differential Differential
Number of drivers 1 Driver 1 driver 1 Driver 32 Driver
and receivers
allowed on one line 1 Receivers 10 Receivers 10 Receivers 32 Receivers
39 COMP2121: Microprocessors and 40
Interfacing

You might also like