0% found this document useful (0 votes)
45 views58 pages

Overview of Serial Communication Protocols

Uploaded by

Murugadas Harnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views58 pages

Overview of Serial Communication Protocols

Uploaded by

Murugadas Harnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Serial Communication

Kamalanath Samarakoon
Serial communication protocols
• Slow
– RS 232 (moderate distance)
– RS485 (long distance)

• Fast (Short distance)


– USB (between devices)
– I2C (IEEE 1384) (between ICs)
– FireWire (between devices)
RS232
• Most popular interface before USB
• Was available in almost all computer to mainframe
• Advantages
– Was commonly available
– Can do that USB could not
– Less number of wires compared to parallel
– Inexpensive
– Very long cable (50 ft max)/USB 16ft // 10-15 ft
– 3 wires to communicate (Unlike parallel)
RS232
• Disadvantages
– Cannot connect more than two devices
– Max speed 20,000 bits/s
– Very long lines need differential interface (RS485)
RS232 Evolution
• Originally
– PC to dumb terminal
• Then
– PC to Internet
• Also PC to
– Mouse
– Printer
– Another PC
– Microcontroller
RS232
• RS (Recommended Standard)
• Standard is – EIA 232F (Electronic Industry
Association)
• This standard defines
– Names and functions of signals
– Electrical Characteristic of signals
– Mechanical standard (size, shape pin assignment)
RS232
• 25 pins or 9 pins
• Logic 0 +3 to +25 V
• Logic 1 -3 to -25 V
• - 3 to +3 V undefined
• O/C V <25 V w.r.t to Ground
• S/C I 500mA driver should be able to drive
• Max speed 20,000 bps for 50 ft
Connectors RS232 – 9 pin

• Equipment
– Female
• Cable
– Male
Link

• RJ Registered Jack of Universal service ordering code


• RJ 11 6 points middle 2 connected
• RJ 14 6 points middle 4 connected
• RJ 25 6 points middle 6 connected
• RJ 45 8 points
• DTE=Data Terminal Equipment (Dumb Terminal/Computer)
• DCE= Data Communication Equipment (Modem)
Standard 9 to 25 pin cable layout for
async data on a PC AT serial cable
Sign 9-pin
Description 25-pin DCE Source DTE or DCE
al DTE
Carrier Detect CD 1 8 from Modem
Receive Data RD 2 3 from Modem
Transmit Data TD 3 2 from Terminal/Computer

Data Terminal Ready DTR 4 20 from Terminal/Computer

Signal Ground SG 5 7 from Modem

Data Set Ready DSR 6 6 from Modem

Request to Send RTS 7 4 from Terminal/Computer

Clear to Send CTS 8 5 from Modem


Ring Indicator RI 9 22 from Modem
Full
Name Function
TD Transmit Data Serial Data Output (TXD)
RD Receive Data Serial Data Input (RXD)
CTS Clear to Send
This line indicates that the Modem is ready to exchange data.
DCD Data Carrier
Detect When the modem detects a "Carrier" from the modem at the
other end of the phone line, this Line becomes active.

DSR Data Set Ready


This tells the UART that the modem is ready to establish a link.
DTR Data Terminal This is the opposite to DSR. This tells the Modem that the UART is
Ready ready to link.
RTS Request To Send This line informs the Modem that the UART is ready to exchange
data.
RI Ring Indicator
Goes active when modem detects a ringing signal from the PSTN.
Null Modem

XX
No Handshake
Full Handshake
Loop back Handshake
USART Universal Asynchronous
Receiver/Transmitter
• IC Module inside the IC for serial
communication
• Do parallel in PC to serial in RS232 conversion
and back
• Supports Half duplex and Full Duplex
• Provide all standard RS232 handshaking and
control lines
• 8250 57600 bps
• 16450 115200 bps
• 16550 16 Bytes FIFO Buffers
• 16650 32 Byte FIFO Buffers
• 16750 64 Byte FIFO Buffers 230,400 bps
Flow control

• Program should set 115,200 kbps and not 33.6


kbps as DCE do compressing
• DTE faster than DCE hence data can be lost
• Hence use flow control
Flow control
• Software
• Xoff – Xon

• Hardware
– Use RTS and DTS lines
Asynchronous communication

Add parity for error detecting


1 8 N 1 = 8N1 1 7 E 1 = 7E1
Parity

8 bits including parity


7 bits of data
(count of 1-bits)
even odd
0000000 0 00000000 00000001
1010001 3 10100011 10100010
1101001 4 11010010 11010011
1111111 7 11111111 11111110
References
• Parallel port, Serial Port and USB
– beyondlogic.org
– http://retired.beyondlogic.org/spp/parallel.htm
• Jan Axelson
– Parallel port complete
– Serial port complete
– USB complete
Asynchronous serial communication by
USART
• UART uses clock that is 16 times bit frequency
• E.g. 300 bps 4800 Hz
• Detect start bit, wait 8, wait 16, read, wait 16, read…
Calculation of bit rate
• In PC UART cock rate is 1.8432 MHz
• Calculate maximum bit rate
Quiz
• In PC UART cock rate is 1.8432 MHz
• Calculate maximum bit rate

• If bit rate is 9600bps


1200 bytes
• How many bytes it can transmit per second?

• How many data bytes it can transmit per second when data
format is 7E1? 960 bytes

• If one data byte represent a ASICI character what is the Baud Rate
960 bytes
Address bus
Control bus

Data bus
Register structure
Device of a PC

Register 1 Write

Base Address

PC
Register 2 Read External
Devices
Base Address+1

Register 3 Read/Write

Base Address+2

Device of a PC = Internal port or Card plugged to Mother


Address decoder
board
Program
# define BASE 0x3F8 (eg. Serial, Parallel 0x378)
# define Reg1 BASE
# define Reg2 BASE+1
# define Reg3 BASE+2
int a = inb(Reg1); //read a byte from the port
outb(Reg2,0xFF); //write a byte to the port

Very important: When writing to registers change the only


bit/s that you want to change and keep others as they are
16550 UART
Block diagram
• PC Bus side
– Data lines
– Read and Write control
– Interrupt control
– Reset
– Address Lines
• RS232 side
• Clock
UART
SN75LBC187

Xin/DLAB= 16xTransmitter Clock


Given as output through BAUDOUT
Can be used as RCLK=Receiver Clock
Registers
• Addresses = Base +7
• 12 registers some read and some write and
R/W using DLAB (Devisor Latch Access Bit)
Registers
Base Address DLAB Read/Write Abr. Register Name

=0 Write - Transmitter Holding Buffer

+0 =0 Read - Receiver Buffer

=1 Read/Write - Divisor Latch Low Byte

=0 Read/Write IER Interrupt Enable Register


+1
=1 Read/Write - Divisor Latch High Byte

- Read IIR Interrupt Identification Register


+2
- Write FCR FIFO Control Register

+3 - Read/Write LCR Line Control Register

+4 - Read/Write MCR Modem Control Register

+5 - Read LSR Line Status Register

+6 - Read MSR Modem Status Register

+7 - Read/Write - Scratch Register


DLAByte
Divisor Latch Divisor Latch
Speed (BPS) Divisor (Dec)
High Byte Low Byte
50 2304 09h 00h
300 384 01h 80h
600 192 00h C0h
2400 48 00h 30h
4800 24 00h 18h
9600 12 00h 0Ch
19200 6 00h 06h
38400 3 00h 03h
57600 2 00h 02h
115200 1 00h 01h
Bit 7
LCR: Line Control Register
1 Divisor Latch Access Bit
Access to Receiver buffer, Transmitter buffer & Interrupt Enable
0
Register
Bit 6 Set Break Enable
Bits 3, 4 And Bit 5 Bit 4 Bit 3 Parity Select
5
X X 0 No Parity
0 0 1 Odd Parity
0 1 1 Even Parity
High Parity
1 0 1
(Sticky)
Low Parity
1 1 1
(Sticky)
Bit 2 Length of Stop Bit
0 One Stop Bit
2 Stop bits for words of length 6,7 or 8 bits or 1.5 Stop Bits
1
for Word lengths of 5 bits.
Bits 0 And 1 Bit 1 Bit 0 Word Length
0 0 5 Bits
0 1 6 Bits
1 0 7 Bits
1 1 8 Bits
MCR: Modem Control Register
Bit Notes
Bit 7 Reserved
Bit 6 Reserved
Autoflow Control Enabled (16750
Bit 5
only)
Bit 4 LoopBack Mode
Bit 3 Aux Output 2
Bit 2 Aux Output 1
Bit 1 Force Request to Send
Bit 0 Force Data Terminal Ready
Modem Status Register
Bit Notes
Bit 7 Carrier Detect
Bit 6 Ring Indicator
Bit 5 Data Set Ready
Bit 4 Clear To Send
Bit 3 Delta Data Carrier Detect
Bit 2 Trailing Edge Ring Indicator
Bit 1 Delta Data Set Ready
Bit 0 Delta Clear to Send
LSR: Line Status Register
Bit Notes
Bit 7 Error in Received FIFO
Bit 6 Empty Data Holding Register
Bit 5 Empty Transmitter Holding Register
Bit 4 Break Interrupt
Bit 3 Framing Error
Bit 2 Parity Error
Bit 1 Overrun Error
Bit 0 Data Ready
IER: Interrupt Enable Register
Bit Notes
Bit 7 Reserved
Bit 6 Reserved
Bit 5 Enables Low Power Mode (16750)
Bit 4 Enables Sleep Mode (16750)
Bit 3 Enable Modem Status Interrupt
Bit 2 Enable Receiver Line Status Interrupt
Bit 1 Enable Transmitter Holding Register Empty Interrupt
Bit 0 Enable Received Data Available Interrupt
IIR: Interrupt Identification Register
Bit Notes
Bits 6 and 7 Bit 6 Bit 7
0 0 No FIFO
0 1 FIFO Enabled but Unusable
1 1 FIFO Enabled
Bit 5 64 Byte Fifo Enabled (16750 only)
Bit 4 Reserved
Bit 3 0 Reserved on 8250, 16450
1 16550 Time-out Interrupt Pending
Bits 1 and 2 Bit 2 Bit 1
0 0 Modem Status Interrupt
0 1 Transmitter Holding Register Empty Interrupt
1 0 Received Data Available Interrupt
1 1 Receiver Line Status Interrupt
Bit 0 0 Interrupt Pending
1 No Interrupt Pending
Programming
• Write steps to set UART to 7E1
• Program the UART to 9600 speed

Set DLAbit =1 (bit 7 of LCR) out(Base+3,0b1XXX XXXX)


Set DLAB Low Byte out(Base, 0xLLLL LLLL)
Set DLAB High Byte out(Base+1, 0xHHHH HHHH)
Set LCR 0001 1010 out(Base+3, 0b0001 1010)
Interfacing
Interfacing RS232 to TTL logic levels
• RS232
Protection
• Galvanic Isolation
– Optical Isolation (Opto couplers)
– Magnetic
• Relay
• Transformer
Protection
• Surge Protection (TVS Diode – Transient
Voltage Diode)
• Over Voltage Protection (Zenor Diode)

Or
TVR vs Zenor Diode
Both operate in reverse biased
TVR vs Zenor Diode
RS423(not wide
SPECIFICATIONS RS232 RS422 RS485
use)
SINGLE SINGLE
Mode of Operation DIFFERENTIAL DIFFERENTIAL
-ENDED -ENDED
Total Number of Drivers and
1 DRIVER 1 DRIVER 1 DRIVER 32 DRIVER
Receivers on One Line (One driver
1 RECVR 10 RECVR 10 RECVR 32 RECVR
active at a time for RS485 networks)
Maximum Cable Length 50 FT. 4000 FT. 4000 FT. 4000 FT.
Maximum Data Rate (40ft. - 4000ft.
20kb/s 100kb/s 10Mb/s-100Kb/s 10Mb/s-100Kb/s
for RS422/RS485)
Maximum Driver Output Voltage +/-25V +/-6V -0.25V to +6V -7V to +12V
Driver Output
Signal Level Loaded +/-5V to +/-15V +/-3.6V +/-2.0V +/-1.5V
(Loaded Min.)
Driver Output
Signal Level Unloaded +/-25V +/-6V +/-6V +/-6V
(Unloaded Max)
Driver Load Impedance (Ohms) 3k to 7k >=450 100 54
Max. Driver
Current in High Z Power On N/A N/A N/A +/-100uA
State
Max. Driver
Current in High Z Power Off +/-6mA @ +/-2v +/-100uA +/-100uA +/-100uA
State
Slew Rate (Max.) 30V/uS Adjustable N/A N/A
Receiver Input Voltage Range +/-15V +/-12V -10V to +10V -7V to +12V
Receiver Input Sensitivity +/-3V +/-200mV +/-200mV +/-200mV
Receiver Input Resistance (Ohms), (1
3k to 7k 4k min. 4k min. >=12k
Standard Load for RS485)
RS 232 Vs RS485
• RS232 Limitations
Speed Distance No of
devices
RS232 20 kbps 50-100 ft 1
RS485 10Mbps 4000ft 25

RS232 Dual supply or expensive V convertion


RS485 Single +5V TTL
How to get a port
USB/RS232 to RS485 converters
Plug into main bus ISA or PCI
Full Duplex
Full duplex multidrop
Half Duplex

You might also like