Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

CHAPTER THREE

INPUT AND OUTUT


INTRODUCTION TO I/O
• Input and Output allows the microcomputer to
interact with its environment
• Data can be sent or received in series or in parallel
synchronously or asynchronously
• Can control the environment through outputs
• Can observe state of environment through inputs
• Specialised standardised interfaces available
• Invariably special cables are used for each interface
• Specialised chip sets provided for each interface type
• Chips interface to the microprocessor through the
three buses and also interface with outside world
RS232 Serial Asynchronous Communications
• Serial communications transmits data one bit after the
other in sequence as opposed to parallel data bits
transmitted at the same time
• Synchronous serial transmission provide both data and
a synchronised clock for use at receiving end
• Asynchronous transmission builds in synchronising
mechanisms to data sent on its own with overheads
• RS232 is a widely used interface for office equipment
and in industry
• Industry standard RS485 is a close variation to RS232
• Uses standard interfaces and signals
• Designed to allow long distance communication
Line Voltages - Drivers and Receivers
• Logic boards use a 5 volt supply and 0V and 5V to
represent Logic ‘0’ and Logic ‘1’ respectively
• Transmission of data over long lines is affected by
noise and interference which can corrupt data
• Increase noise immunity by increasing voltage
difference between signal levels for ‘0’ and ‘1’
• RS232 originally used +12V (‘0’) and -12V (‘1’)
• 1488 Line drivers and 1489 line receivers were used
• Required +12V, -12V and +5V supplies to function
• MAX232 Line driver receiver chips uses only 5V
• Includes two line drivers and two line receivers
• Two voltage levels reduces to +10 and -10V
Inverting Line Drivers and Line Receivers
• TTL ‘0’ or 0V converted to +10V (+12V)
• TTL ‘1’ or 5V converted to -10V (-12)
• Minimum amplitude of received signal is +/-3V
• MAX232 chip has internal switching circuits which
convert +5V to +10V and -10V with the use of external
capacitors
TTL Side and Levels Line Driver RS232 Side and Levels

Logic ‘1’ (5V) Inactive (-10V)


Logic ‘0’ (0V) Active (+10V)
Line Receiver
Logic ‘1’ (5V) Inactive (-10V)
Logic ‘0’ (0V) Active (+10V)
MAX232 CHIP
FUNCTIONAL BLOCK DIAGRAM
5V • Electrolytic capacitors
+ -
2 16 are 1 mF or 10 mF
1 4
+ +
- -
3 5
14 11
13 12
RS232 SIDE TTL SIDE

7 10

8 9
15 + - 6
DB25 and DB9 SIGNAL ALLOCATIONS
DB25 DB9 SIGNAL NAME
1 Frame Ground /Chassis Ground
2 3 TxD (Transmitted Data)
3 2 RxD (Received Data)
4 7 RTS (Request To Send)
5 8 CTS (Clear To Send)
6 6 DSR (Data Set Ready)
7 5 GND (Logic Ground)
8 1 DCD (Data Carrier Detect)
20 4 DTR (Data Terminal Ready)
22 9 RING (Ring Indication)
RS232 CHARACTER FRAME
ASCII CHARACTER ‘A’ ASCII CODE $41 - 100 0001
TTL FRAME
IDLE

START BIT 0 BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 EVEN STOP BITS
BIT LSB PARITY
Character Frame
7 data bits per ASCII Character

IDLE
RS232 FRAME
SYNCHRONISING TO INCOMING FRAME

5 6 7 0 1 2 3 4 5 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Local Clock 8 times the data bit rate (x16) is common


Character ‘U’ ASCII Code $55 and Even Parity

Local clock frequency higher than transmitter clock frequency


Character ‘3’ ASCII Code $33 and Even Parity

Local clock frequency lower than transmitter clock frequency


EIGHT DATA BITS PER BYTE CHARACTER
$96 Odd Parity, One Stop Bit

IDLE 0 1 1 0 1 0 0 1 1 1

START BIT 0 BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 ODD STOP
BIT LSB MSB PARITY BIT

$7A Odd Parity, One Stop Bit

IDLE 0 1 0 1 1 1 1 0 0 1

$6D Odd Parity, One Stop Bit

IDLE 1 0 1 1 0 1 1 0 0 1
RS232 CONFIGURATION
BAUD RATE PARITY SETTINGS WORD LENGTH
19200 bps ODD Parity 5 bits/char
9600 bps EVEN Parity 6 bits/char
4800 bps NO PARITY 7 bits/char
1200 bps MARK PARITY 8 bits/char
600 bps SPACE PARITY
300 bps STOP BITS
150 bps 1 STOP Bit
110 bps 1.5 STOP Bits
2 STOP Bits
Settings must be identical on either side of the serial link
LINK UTILSATION EFFICIENCY
• Asynchronous transmission has overheads. Start bit,
Parity bit and Stop bit(s) to convey the actual data bits per
character. Stop bits and Start bits required for character
synchronisation
• Link utilisation efficiency is data bits in character divided
by total number of bits in the frame expressed as %
• Maximum byte or character transfer rate is Baud Rate
divided by the total number of bits in the character frame
• For first example: Efficiency = 7/11 = 63.63%
• For second example: Efficiency = 8/11 = 72.7%
• Maximum transfer rates are both 19200/11 = 1745.45
characters or bytes per second
Matching RS232 settings
• Mismatched settings can result in errors on the
serial link
• Banks of DIP switches can be used to select the
correct settings so they match the settings on the
other end of the serial link
• Software is available to configure the serial link to
the desired settings
• A protocol analyser or data communications tester
can be used to determine the settings available
• Data communications tester can send test messages
like all the lower and upper case and digit
characters and the “QUICK BROWN FOX” message
RS232 Errors
• RS232 uses simple parity to detect errors
• Simple Parity can only detect an ODD number of
bit errors.
• Errors can always be reduced by reducing the data
bit rate
• A Framing Error results when one or more STOP
bits are missing
• Large mismatch between the transmitter clock and
the receiver clock can also cause errors, especially
framing errors and parity errors
• Character overruns can be prevented by interrupts

You might also like