Navigation :
Untitled Document
Interfacing Devices to RS-232 Ports


So far we have introduced RS-232 Communications in relation to the PC. RS-232 communication is asynchronous. That is a clock signal is not sent with the data. Each word is synchronized using it's start bit, and an internal clock on each side, keeps tabs on the timing.

Serial Waveforms - Logic Levels
TTL/CMOS Serial Logic Waveform

The diagram above, shows the expected waveform from the UART when using the common 8N1 format. 8N1 signifies 8 Data bits, No Parity and 1 Stop Bit. The RS-232 line, when idle is in the Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then each bit is sent down the line, one at a time. The LSB (Least Significant Bit) is sent first. A Stop Bit (Logic 1) is then appended to the signal to make up the transmission.
The diagram, shows the next bit after the Stop Bit to be Logic 0. This must mean another word is following, and this is it's Start Bit. If there is no more data coming then the receive line will stay in it's idle state(logic 1). We have encountered something called a "Break" Signal. This is when the data line is held in a Logic 0 state for a time long enough to send an entire word. Therefore if you don't put the line back into an idle state, then the receiving end will interpret this as a break signal.

The data sent using this method, is said to be framed. That is the data is framed between a Start and Stop Bit. Should the Stop Bit be received as a Logic 0, then a framing error will occur. This is common, when both sides are communicating at different speeds.

The above diagram is only relevant for the signal immediately at the UART. RS-232 logic levels uses +3 to +25 volts to signify a "Space" (Logic 0) and -3 to -25 volts for a "Mark" (logic 1). Any voltage in between these regions (ie between +3 and -3 Volts) is undefined. Therefore this signal is put through a "RS-232 Level Converter". This is the signal present on the RS-232 Port of your computer, shown below.

 RS-232 Waveforms
RS-232 Logic Waveform

The above waveform applies to the Transmit and Receive lines on the RS-232 port. These lines carry serial data, hence the name Serial Port. There are other lines on the RS-232 port which, in essence are Parallel lines. These lines (RTS, CTS, DCD, DSR, DTR, RTS and RI) are also at RS-232 Logic Levels.

Almost all digital devices which we use require either TTL or CMOS logic levels. Therefore the first step to connecting a device to the RS-232 port is to transform the RS-232 levels back into 0 and 5 Volts. As we have already covered, this is done by RS-232 Level Converters.

Two common RS-232 Level Converters are the 1488 RS-232 Driver and the 1489 RS-232 Receiver. Each package contains 4 inverters of the one type, either Drivers or Receivers. The driver requires two supply rails, +7.5 to +15v and -7.5 to -15v. As you could imagine this may pose a problem in many instances where only a single supply of +5V is present. However the advantages of these I.C's are they are cheap.

Pinout for MAX-232 RS-232 Level Converter

Above: Pinouts for the MAX-232,
RS-232 Driver/Receiver.



Right: Typical MAX-232 Circuit.


Typical MAX-232 Circuit
Another device is the MAX-232. It includes a Charge Pump, which generates +10V and -10V from a single 5v supply. This I.C. also includes two receivers and two transmitters in the same package. This is handy in many cases when you only want to use the Transmit and Receive data Lines. You don't need to use two chips, one for the receive line and one for the transmit. However all this convenience comes at a price, but compared with the price of designing a new power supply it is very cheap.

There are also many variations of these devices. The large value of capacitors are not only bulky, but also expensive. Therefore other devices are available which use smaller capacitors and even some with inbuilt capacitors. (Note : Some MAX-232's can use 1 micro farad Capacitors). However the MAX-232 is the most common, and thus we will use this RS-232 Level Converter in our examples.

In order to do anything useful with our Serially transmitted data, we must convert it back to Parallel. (You could connect an LED to the serial port and watch it flash if you really want too, but it's not extremely useful). This in the past has been done with the use of UART's. However with the popularity of cheap Microcontroller's, these can be more suited to many applications. We will look into the advantages and disadvantages of each method.

 
We have already looked at one type of UART, the 8250 and compatibles found in your PC. These devices have configuration registers accessible via the data and address buses which have to be initialized before use. This is not a problem if your device which you are building uses a Microprocessor. However if you are making a stand alone device, how are you going to initialize it?

Most Microprocessors / Microcontrollers these days can be brought with build-in Serial Communication Interfaces (SCI). Therefore there is little need to connect a 40 pin 16550 to, for example a 68HC11 when you can buy one built in. If you are still in love with the Z-80 or 8086 then an 16550 may be option! (or if you are like myself, the higher chip count the better. After all it looks more complicated and impressive! - But a headache to debug!)

Pin Diagrams of UARTs - 16550, 16450 & 8250
Pin Diagrams for 16550, 16450 & 8250 UARTs


Pin No. Name Notes
Pin 1:8 D0:D7 Data Bus
Pin 9 RCLK Receiver Clock Input. The frequency of this input should equal the receivers baud rate x 16
Pin 10 RD Receive Data
Pin 11 TD Transmit Data
Pin 12 CS0 Chip Select 0 - Active High
Pin 13 CS1 Chip Select 1 - Active High
Pin 14 nCS2 Chip Select 2 - Active Low
Pin 15 nBAUDOUT Baud Output - Output from Programmable Baud Rate Generator. Frequency = (Baud Rate x 16)
Pin 16 XIN External Crystal Input - Used for Baud Rate Generator Oscillator
Pin 17 XOUT External Crystal Output
Pin 18 nWR Write Line - Inverted
Pin 19 WR Write Line - Not Inverted
Pin 20 VSS Connected to Common Ground
Pin 21 RD Read Line - Inverted
Pin 22 nRD Read Line - Not Inverted
Pin 23 DDIS Driver Disable. This pin goes low when CPU is reading from UART. Can be connected to Bus Transceiver in case of high capacity data bus.
Pin 24 nTXRDY Transmit Ready
Pin 25 nADS Address Strobe. Used if signals are not stable during read or write cycle
Pin 26 A2 Address Bit 2
Pin 27 A1 Address Bit 1
Pin 28 A0 Address Bit 0
Pin 29 nRXRDY Receive Ready
Pin 30 INTR Interrupt Output
Pin 31 nOUT2 User Output 2
Pin 32 nRTS Request to Send
Pin 33 nDTR Data Terminal Ready
Pin 34 nOUT1 User Output 1
Pin 35 MR Master Reset
Pin 36 nCTS Clear To Send
Pin 37 nDSR Data Set Ready
Pin 38 nDCD Data Carrier Detect
Pin 39 nRI Ring Indicator
Pin 40 VDD + 5 Volts
Pin Assignments for 16550A UART CDP6402, AY-5-1015 / D36402R-9 etc UARTs


Pinout for CDP6402, AY-5-1015 / D36402R-9 UARTs 
Pinout of CDP6402
There are UARTs such as the CDP6402, AY-5-1015 / D36402R-9 and compatibles. These differ from the 8250 and compatibles, by the fact that they have separate Receive and Transmit data buses and can be configured by connecting certain pins to various logic levels. These are ideal for applications where you don't have a Microprocessor available. Such an example is if you want to connect a ADC0804 (Analog to Digital Converter) to the UART, or want to connect a LCD Display to the Serial Line. These common devices use a 8 bit parallel data bus.

The CDP6402's Control Register is made up of Parity Inhibit (PI), Stop Bit Select (SBS), Character Length Select (CLS1 and 2) and Even Parity Enable (EPE). These inputs can be latched using the Control Register Load (CRL) or if you tie this pin high, changes made to these pins will immediately take effect.


Pin Number
Abbr.
Full Name
Notes
Pin 1
VDD
+ 5v Supply Rail
Pin 2
NC
Not Connected
Pin 3
GND
Ground
Pin 4
RRD
Receiver Register Disable
When driven high, outputs RBR8:RBR1 are High Impedance.
Pin 5:12
RBR8:
RBR1
Receiver Buffer Register
Receiver's Data Bus
Pin 13
PE
Parity Error
When High, A Parity Error Has Occurred.
Pin 14
FE
Framing Error
When High, A Framing Error Has Occurred. i.e. The Stop Bit was not a Logic 1.
Pin 15
OE
Overrun Error
When High, Data has been received but the nData Received Reset had not yet been activated.
Pin 16
SFD
Status Flag Disable
When High, Status Flag Outputs (PE, FE, OE, DR and TBRE) are High Impedance
Pin 17
RRC
Receiver Register Clock
x16 Clock input for the Receiver Register.
Pin 18
nDRR
Data Received Reset
Active Low. When low, sets Data received Output Low (i.e. Clears DR)
Pin 19
DR
Data Received
When High, Data has been received and placed on outputs RBR8:RBR1.
Pin 20
RRI
Receiver Register In
RXD - Serial Input. Connect to Serial Port, Via RS-232 receiver.
Pin 21
MR
Master Reset
Resets the UART. UART should be reset after applying power.
Pin 22
TBRE
Transmitter Buffer Register Empty
When High, indicates that Transmitter Buffer Register is Empty, thus all bits including the stop bit have been sent.
Pin 23
nTBRL
Transmitter Buffer Load / Strobe
Active Low. When low, data present on TBR8:TBR1 is placed in Transmitter Buffer Register. A Low to High Transition on this pin, then sends the data.
Pin 24
TRE
Transmitter Register Empty
When High, Transmitter Register is Empty, thus can accept another byte of data to be sent.
Pin 25
TRO
Transmitter Register Out (TXD)
TXD - Serial Output. Connect to Serial Port, Via RS-232 Transmitter.
Pin 26:33
TBR8:
TBR1
Transmitter Buffer Register
Data Bus, for Transmitter. Place Data here which you want to send.
Pin 34
CRL
Control Register Load
When High, Control Register (PI, SBS, CLS2, CLS1, EPE) is Loaded. Can be tied high, so changes on these pins occur instantaneously.
Pin 35
PI
Parity Inhibit
When High, No Parity is Used for Both Transmit and Receive. When Low, Parity is Used.
Pin 36
SBS
Stop Bit Select
A High selects 2 stop bits. (1.5 for 5 Character Word Lengths) A Low selects one stop bit.
Pin 37:38
CLS2:
CLS1
Character Length Select
Selects Word Length. 00 = 5 Bits, 01 = 6 Bits, 10 = 7 Bits and 11 = 8 Bits.
Pin 39
EPE
Even Parity Enable
When High, Even Parity is Used, When Low, Odd Parity is Used.
Pin 40
TRC
Transmitter Register Clock
16x Clock input for Transmitter.
Pin Description for CDP6402, AY-5-1015 / D36402R-9 and compatible UART's


However one disadvantage of these chips over the 8250's is that these UART's have no inbuilt Programmable Baud Rate Generator, and no facility to connect a crystal directly to it. While there are Baud Rate Generator Chips such as the AY-5-8116, a more cheaper (and common) alternative is the 74HC4060 14-bit Binary Counter and Oscillator.

The 74HC4060, being a 14 bit binary counter/divider only has outputs for some of it's stages. Only Q4 to Q14 is available for use as they have external connections. This means higher Baud Rates are not obtainable from common crystals, such as the 1.8432 Mhz and 2.4576 Mhz. The UART requires a clock rate 16 times higher than the Baud Rate you will be using. eg A baud rate of 9600 BPS requires a input clock frequency of 153.6 Khz.

Baud Rate Generator using a 74HC4060
Baud Rate Generator using a 74HC4060
Output 1.8432Mhz 2.4546Mhz
Out 2 115.2 KBPS 153.6 KBPS
Q4 7200 BPS 9600 BPS
Q5 3600 BPS 4800 BPS
Q6 1800 BPS 2400 BPS
Q7 900 BPS 1200 BPS
Q8 450 BPS 600 BPS
Q9 225 BPS 300 BPS
Possible Baud Rates using a 74HC4060

The 1.8432 Mhz crystal gives some unfamiliar Baud Rates. While many of these won't be accepted by terminal programs or some hardware, they are still acceptable if you write your own serial programs. For example the PC's baud rate divisor for 7200 BPS is 16, 3600 BPS is 32, 1800 BPS is 64 etc. If you require higher speeds, then it is possible to connect the UART to the OUT2 pin. This connection utilizes the oscillator, but has no frequency division applied. Using OUT2 with a 1.8432 Mhz crystal connected gives a baud rate of 115,200 BPS. The CMOS CDP6402 UART can handle up to 200 KBPS at 5 volts, however your MAX-232 may be limited to 120 KBPS, but is still within range.
Last modified at : Thursday, December 11st 2008 14:02:04.
Home
Bahasa Indonesia
122380 Times
1 online
Anyone who has never made a mistake has never tried anything new.

Albert Einstein

Administrator srugN - Electronic Engineering Polytechnic Institute of Surabaya