0% found this document useful (0 votes)
35 views15 pages

28-Rs232 Interfacing-12-04-2024

The document discusses the RS-232 serial communication standard including its history, characteristics, pinouts, and how to interface with it. RS-232 was commonly used to connect computers and peripherals but has been replaced by faster standards like USB. It describes the key aspects of RS-232 like asynchronous communication, start/stop bits, baud rates, and how to implement transmitters and receivers.

Uploaded by

Gunner 14
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)
35 views15 pages

28-Rs232 Interfacing-12-04-2024

The document discusses the RS-232 serial communication standard including its history, characteristics, pinouts, and how to interface with it. RS-232 was commonly used to connect computers and peripherals but has been replaced by faster standards like USB. It describes the key aspects of RS-232 like asynchronous communication, start/stop bits, baud rates, and how to implement transmitters and receivers.

Uploaded by

Gunner 14
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/ 15

Interfacing RS232 – Serial Port

Dr Arunachalam,
Associate Professor, SENSE
Recommended Standard (RS)-232
• A serial port complying with the RS-232 standard was once a standard feature of many types of
computers.
• RS232 connector is a port used for data exchange between equipment.
• It was designed for data exchange between Data Terminal Equipment (DTE) and Data
Communication Equipment (DCE); for example, PC & MODEM.
• The need for RS232 came from limitations raised by parallel data exchange.
• RS232 uses a serial communication protocol where data exchange is done bit by bit.
• RS232 used to have 25 pins, now it is shrunk to just 9 pins.
• Although RS232 is later replaced by a faster USB (Universal Serial Bus); it is still popular in
some areas.
Suitable Usage
• Simple asynchronous communication interface between two units.
• A two-pin full duplex communication can be established easily on the RS232 port.
• RS232 is used in systems where clock sharing is difficult.
• RS232 is ASYNCHRONOUS so there will be no clock sharing between systems.
• But need to set data bit rate (baud rate) for each unit.
• Once the baud rate is set the units will sample the data accordingly.
• RS232 is also used to control a single unit specifically without delay or errors.
• RS232 interface also delivers data with more accuracy which is a requirement in some cases.
• As it obtains the voltage for the path used for the data exchange between the devices.
• It is used in serial communication up to 50 feet with a rate of 1.492kbps.
Characteristics
• Asynchronous communication
• Baud rate is used to measure the speed of transmission.
• Baud rate and bits per second (BPS) are the same when we connect directly two terminals.
• For example, if the baud rate is 200 then 200 bits per Sec passed.
• In telephone lines, the baud rates will be 14400, 28800 and 33600. Here BPS could be different.

• Stop Bits are used for a single packet to stop the transmission which is denoted as “T”.
• Some typical values are 1, 1.5 & 2 bits.

• Parity Bit is the simplest form of checking the errors.


• There are four kinds, i.e., even, odd, marked and spaced.
• For example, If 011 is a number the parity bit = 0, i.e., even parity and the parity bit = 1, i.e., odd parity.
Connection & data packet

Synchronous communication Using 3 wires, Data can be sent and


receive.

• Data is commonly sent in


chunks of 8 bits (a byte)
and is "serialized“.
• The LSB (b0) is sent first,
then bit b1, ... and finally
the MSB (b7).
• 1 start/idle bit (0/1), two
stop bit (1) and a parity bit
(1 for odd, 0 for even
parity)
Example: Byte 0x55 when transmitted
• Byte 0x55 is 0101 0101 in binary.
• But since it is transmitted LSB (bit-0) first, the line toggles like that: 1-0-1-0-1-0-
1-0.
Pin details - DB-9
PIN
Pin Name Pin Description
No.
1 DCD (Carrier Detect) Incoming signal from DCE

2 RXD (Receive Data) Receives incoming data from DTE

3 TXD (Transmit Data) Send outgoing data to DCE

4 DTR (Data Terminal Ready) Outgoing handshaking signal

5 GND (Signal ground) Common reference voltage

6 DSR (Data Set Ready) Incoming handshaking signal

7 RTS (Request to Send) Outgoing signal for controlling flow

8 CTS (Clear to Send) Incoming signal for controlling flow

9 RI (Ring Indicator) Incoming signal from DCE

Can communicate at a maximum speed of roughly 10KBytes/s


How fast can we send data?
• Common implementations of the RS-232 interface must settle to some "standard" speed.
• Common values are 1200, 9600, 38400, and 115200 bauds (usually the fastest).
• At 115200 bauds, each bit lasts for (1/115200= 8.7µs).
• If you transmit 8-bit data, that lasts 8 × 8.7µs = 69µs.
• But each byte requires an extra start and stop bit, so we need 10 x 8.7µs = 87µs. That translates to a
maximum speed of 11.5KBytes per second.
• At 115200 bauds, some PCs with buggy chips require a "long" stop bit (1.5 or 2 bits long...) which
makes the maximum speed drop to around 10.5KBytes per second.
Baud Generator
• The serial link at maximum speed, i.e. 115200 bauds.
• FPGAs usually run at MHz speeds, well above 115200Hz (RS-232 is pretty slow by today's
standards).
• We need to find a way to generate (from the FPGA clock) a "tick" as close as possible to 115200
times a second.
• Traditionally, RS-232 chips use a 1.8432MHz clock, because that makes generating the standard
baud frequencies very easy 1.8432MHz divided by 16 gives 115200Hz.
If 2MHz instead of 1.8432MHz clock, then?
• To generate 115200Hz from a 2MHz clock, we need to divide the clock by "17.361111111..." Not
exactly a round number.
• The solution is to divide sometimes by 17, sometimes by 18, making sure the ratio stays
"17.361111111"
RS-232 Transmitter
• An "async transmitter" with fixed parameters: 8 data bits, 2 stop bits, no-parity.
It works like that:
• The transmitter takes an 8-bits data inside the FPGA and serializes it (starting when the
"TxD_start" signal is asserted).
• The "busy" signal is asserted while a transmission occurs (the "TxD_start" signal is ignored during
that time).
RS-232 Receiver
• The module assembles data from the RxD line as it comes.
• As a byte is being received, it appears on the "data" bus. Once a complete byte has been received,
"data_ready" is asserted for one clock.
• Note that "data" is valid only when "data_ready" is asserted. The rest of the time, don't use it as
new data may come that shuffles it.
Oversampling
• An asynchronous receiver must get in-sync with the incoming signal (it normally doesn't have
access to the clock used by the transmitter).
• To determine when a new data byte is coming, we look for the "start" bit by oversampling the
signal at a multiple of the baud rate frequency.
• Once the "start" bit is detected, we sample the line at the known baud rate to acquire the data bits.
• Receivers typically oversample the incoming signal at 16 times the baud rate. We use it 8 times
here... For 115200 bauds, that gives a sampling rate of 921600Hz.
References
• Fundamentals of RS-232 Serial Communications | Analog Devices
• What is RS232 Protocol and How it Works? - Codrey Electronics
• RS232 Connector Pinout, Configuration, Features, Circuit & Datasheet (components101.com)
• What is RS232 Serial Communication Protocol? RS232 Basics, Working & Specifications
(circuitdigest.com)
• fpga4fun.com - Serial interface (RS-232)
Next class
Audio & Video interface

You might also like