Professional Documents
Culture Documents
Unit 6: 6.1 8255 Programmable Peripheral Interface and Interfacing
Unit 6: 6.1 8255 Programmable Peripheral Interface and Interfacing
1
6.1.1 Control Logic of 8255
RD (Read) : This signal enables the Read operation. When the signal is low,
microprocessor reads data from a selected I/O port of 8255.
CS , A0, A1 : These are device select signals. is connected to a decoded address and
A0, A1 are connected to A0, A1 of microprocessor.
A1 A0 Selected
CS
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control
Register
1 x x 8255 is not
selected
2
Fig. 6.2 Block Diagram of 8255
3
Fig. 6.3 BSR Mode of 8255
4
Fig. 6.4 Mode 1 Input Control Signals
STB (Strobe Input) : This signal (active low) is generated by a peripheral device
that it has transmitted a byte of data. The 8255, in response to , generates IBF and
INTR.
IBF (Input buffer full) : This signal is an acknowledgement by the 8255 to indicate
that the input latch has received the data byte. This is reset when the microprocessor
reads the data.
INTR (Interrupt Request) : This is an output signal that may be used to interrupt
the microprocessor. This signal is generated ifSTB , IBF and INTE are all at logic 1.
INTE (Interrupt Enable) : This is an internal flip-flop to a port and needs to be set to
generate the INTR signal. The two flip-flops INTEA and INTEB are set /reset using
the BSR mode. The INTEA is enabled or disabled through PC4 , and INTEB is
enabled or disabled through PC2 .
5
Fig. 6.5 Timing Waveforms of Mode 1 input operation
6
Fig. 6.6 Mode 1 Ounput Control Signals
OBF (Output Buffer Full) : This is an output signal that goes low when the
microprocessor writes data into the output latch of the 8255. This signal indicates to an
output peripheral that new data is ready to be read. It goes high again after the 8255
receives a signal from the peripheral.
ACK (Acknowledge) : This is an input signal from a peripheral that must output a low
when the peripheral receives the data from the 8255 ports.
INTR (Interrupt Request) : This is an output signal, and it is set by the rising edge of
the ACK signal. This signal can be used to interrupt the microprocessor to request the
next data byte for output. The INTR is set when OBF
, , ACK and INTE are all one and
reset by the rising edge of WR. .
INTE (Interrupt Enable) : This is an internal flip-flop to a port and needs to be set to
generate the INTR signal. The two flip-flops INTEA and INTEB are set /reset using the
BSR mode. The INTEA signal can be enabled or disabled through PC6 , and
INTEB is enabled or disabled through PC2 .
7
This mode is used primarily in applications such as data transfer between the two
computers or floppy disk controller interface. Port A can be configured as the
bidirectional port and Port B either in mode 0 or mode 1. Port A uses five signals from
Port C as handshake signals for data transfer. The remaining three lines from Port C can
be used either as simple I/O or as handshake signals for Port B.
8
The analog to digital converter is treated as an input device by the
microprocessor that sends an initialising signal to the ADC to start the
analog to digital data conversation process. The start of conversion signal is
a pulse of a specific duration. The process of analog to digital conversion is
a slow process, and the microprocessor has to wait for the digital data till
the conversion is over. After the conversion is over, the ADC sends end of
conversion (EOC) signal to inform the microprocessor that the conversion
is over and the result is ready at the output buffer of the ADC. These tasks
of issuing an SOC pulse to ADC, reading EOC signal from the ADC and
reading the digital output of the ADC are carried out by the CPU using
8255 I/O ports.
The time taken by the ADC from the active edge of SOC pulse (the
edge at which the conversion process actually starts) till the active edge of
EOC signal is called as the conversion delay of the ADC. Or broadly
speaking the time taken by the converter to calculate the equivalent digital
data output from the instant of the start of conversion is called conversion
delay. It may range any where from a few microseconds in case of fast
ADCs to even a few hundred milliseconds in case of slow ADCs. A number
of ADCs are available in the market, The selection of ADC for a particular
application is done, keeping in mind the required speed, resolution range of
operation, power supply requirements, sample and hold device
requirements and the cost factors are considered.
9
and Hold circuit. If the applied input changes before the complete conversion
process is over, the digital equivalent of the analog input calculated by the ADC
may not be correct.
ADC 0808/0809
The analog to digital converter chips 0808 and 0809 are 8-bit CMOS,
successive approximation converters. Successive approximation technique is
one of the fast techniques for analog to digital conversion. The conversion
delay is 100 s at a clock frequency of 640 kHz, which is quite low as
compared to other converters. These converters do not need any external
zero or full scale adjustments as they are already taken care of by internal
circuits. These converters internally have a 3:8 analog multiplexer so that at
a time eight different analog inputs can be connected to the chips. Out of
these eight inputs only one can be selected for conversion by using address
lines ADD A, ADD B and ADD C, as shown. Using these address inputs,
multichannel data acquisition systems can be designed using a single ADC.
The CPU may drive these lines using output port lines in case of
multichannel applications. In case of single input applications, these may be
hard wired to select the proper input.
10
Fig.1. Block Diagram of ADC 0808/0809
only positive analog input voltages to their digital equivalents. These chips
do not contain any internal sample and hold circuit. If one needs a sample
and hold circuit for the conversion of fast, signals into equivalent digital
quantities, it has to be externally connected at each of the analog inputs.
Figure1 shows the block diagram and Figure 2 shows the pin diagram for
ADC 08/0809.
I/P0-I/P7
Analog inputs
ADD A, B, C
Fig.2. Pin Diagram of ADC 0808/0809
11
Vref+ Not more than +5V
Vref- Not less than GND
+Vcc supply +5V DC
Logical 1 i/p voltage minimum Vcc -1.5V
Logical 0 i/p voltage maximum 1.5V
Logical 1 o/p voltage minimum Vcc -0.4V
Logical 0 o/p voltage maximum 0.45V
Till now we have studied the necessary details of the analog to digital
converter chips 0808/0809. Now we consider some interfacing examples of
these chips with 8086 so that the working of these ADCs will be absolutely
clear along with the required algorithms for interfacing.
Example: Interface ADC 0808 with 8086 using 8255 ports. Use Port A of 8255
for transferring digital data output of ADC to the CPU and Port C for control
signals. Assume that an analog input is present at I/P2 of the ADC and a clock
input of suitable frequency is available for ADC. Draw the schematic and write
required ALP.
Solution
Figure 4 shows the interfacing connections of ADC0808 with 8086 using 8255.
The analog input I/P2 is used and therefore address pins A, B, C should be 0,1,0
respectively to select I/P2. The OE and ALE pins are already kept at +5V to select
the ADC and enable the outputs. Port C upper acts as the input port to receive the
EOC signal while port C lower acts as the output port to send SOC to the ADC.
12
Port A acts as a 8-bit input data port to receive the digital data output from the
ADC. The 8255 control word is written as follows:
D7 D6 D5 D4 D3 D2 Dl Do Control word
1 0 0 1 1 0 0 0 = 98 H
13
INTERFACING DIGITAL TO ANALOG ONVERTERS:
The digital to analog converters convert binary numbers into their analog
equivalent voltages or currents. Several techniques are employed for digital to
analog conversion.
i. Weighted resistor network
ii. R-2R ladder network
iii. Current output D/A converter
The DAC find applications in areas like digitally controlled gains, motor speed
control, programmable gain amplifiers, digital voltmeters, panel meters, etc. D/A
converter have many applications besides those where they are used with a
microcomputer. In a compact disk audio player for example a 14-or16-bit D/A
converter is used to convert the binary data read off the disk by a laser to an
analog audio signal. Most speech synthesizer integrated circuits contain a D/A
converter to convert stored binary data words into analog audio signals.
Characteristics
1. Resolution: It is a change in analog output for one LSB change in digital input.
It is given by(1/2n )*Vref. If n=8 (i.e.8-bit DAC)
1/256*5V=39.06mV
2. Settling time: It is the time required for the DAC to settle for a full scale code
change.
14
Interfacing of DAC0800 with 8086:
15
A stepper motor is a device used to obtain an accurate position control of rotating
shafts. A stepper motor employs rotation of its shaft in terms of steps, rather than
continuous rotation as in case of AC or DC motors. To rotate the shaft of the
stepper motor, a sequence of pulses is needed to be applied to the windings ofthe
stepper motor, in proper sequence. The number of pulses required for one
complete rotation of the shaft of the stepper motor are equal to its number of
internal teeth on its rotor. The stator teeth
and the rotor teeth lock with each other to
fix a position of the shaft. With a pulse
applied to the winding input, the rotor
rotates by one teeth position or an angle x.
The angle x may be calculated as.
x =360 /no. of rotor teeth
A typical stepper motor may have parameters like torque 3 kg-em, operating
voltage 12V, current rating 1.2A and a step angle 1.80, i.e. 200 steps/revolution
(number of rotor teeth).
16
A simple scheme for rotating the shaft of a stepper motor is called as wave
scheme. In this scheme, the windings Wa, Wb, We and Wd are applied with the
required voltage pulses, in a cyclic fashion. By reversing the sequence of
excitation, the direction of rotation of the stepper motor shaft may be reversed.
Table 1 shows the excitation sequences for clockwise and anticlockwise rotations.
Another popular scheme for rotation of a stepper motor shaft applies pulses to two
successive windings at a time but these are shifted only by one position at a time.
This scheme for rotation of stepper motor shaft is shown in Table 1.
Table 1 excitation Sequences of a Stepper Motor Using Wave Switching Scheme
Motion Step A B C D
Clockwise 1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
5 1 0 0 0
Anticlock wise 1 1 0 0 0
2 0 0 0 1
3 0 0 1 0
4 0 1 0 0
5 1 0 0 0
Fig.
ALP FOR 1.3 Interfacing
STEPPER MOTOR Stepper Motor winding
TO ROTATE Wa
CLOCKWISE/ ANTICLOCKWISE
DIRECTION FOR N ROTATIONS.
DATA SEGMENT
PORTA EQU 0C800H
PORTB EQU 0C801H
PORTC EQU 0C802H
CWR EQU 0C803H
17
PHA EQU 077H
PHB EQU 0BBH
PHC EQU 0DDH
PHD EQU 0EEH
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
18
OUT DX, AL
MOV BL, 60H
K1: MOV CX, 0FFFFH
K2: LOOP K2
DEC BL
JNZ K1
RET
STEP ENDP
CODE ENDS
END START
19
4. The SLCT signal on pin13, which goes high if the printer is selected for
receiving data
5. The ERROR signal on pin32, which goes low for a variety of problem
conditions in the printer.
20
Fig1.1 Printer Interface with 8255
21
Example: Interface a standard IEEE-488 parallel bus printer with 8086. Draw the
necessary hardware scheme required for the same and write an ALP to print a
character whose ASCII code is available in AL.
Solution: Before going through this solution, one should refer to the standard
Centronix, INB or EPSON printer pin configuration, given in Table 5.11. There
are two types of parallel cables used to connect a microcomputer with a printer,
viz. 25 pin cables and 36 pin cables. Basically the 25 pin and the 36 pin cables are
similar except for the 11 extra pins for ground (GND) used as 'RETURN' lines for
different signals.
The group A is used in mode 1 for handshake data transfer so that
port A is used for data transfer and port Clines PC3-PC5 are used as
handshake lines. Port B lines are used for checking the printer status;
hence port B is used as input port in mode o. Port C lower is used as output
port for enabling the printer. The control words are shown in Fig. 1.4
Pin Connections and Descriptions for Centronix-type Parallel
Table 5.11
Interface to IBM PC and EPSON FX-l 00 Printers
Printer Controller
Signal Return Directi
Signal Description
Pin No. Pin No. on
--- STROBE pulse to read data in. Pulse width
must be morE
than 0.5 f..ls at receiving terminal. The signal
1 19 STROBE IN level is normally "high"; read-in of data is
performed at the "low" level of this signal.
2 20 DATA 1 IN
These signals represent information of the 1st
to 8th bits
3 21 DATA 2 IN
of parallel data respectively. Each signal is at
"high"
4 22 DATA 3 IN
level when data is logical "1" and "low" when
logical "0".
5 23 DATA 4 IN
6 24 DATA 5 IN
7 25 DATA 6 IN
8 26 DATA 7 IN
9 27 DATA 8 IN
22
A "high" signal indicates that the printer
cannot receive
17 - CHASIS
Printer chasis GND. In the printer, the chasis
GND and
GND the logic GND are isolated from each other.
18 - NC - Not used.
19-30 - GND - "Twisted-Pair Return" signal; GND level.
--
When the level of this signal becomes "low"
the printer
controller is reset to its initial state and the
31 - IN IT IN
print buffer
is cleared. This signal is normally at "high"
level,
pulse and
widthits must be more than 50 J.ts at the
receiving
The level terminal.
of this signal becomes "low" when
32 ERROR OUT
the printer is "state, "Ofline" state and "Error"
in "Paper End
state.
33 - GND - Same as with pin numbers 19 to 30.
34 - NC - Not used.
35 Pulled up to + 5 Vdc through 4.7 k-ohms
resistance.
Data entry to the printer is possible only when
the level
23
of this signal is "low". (Internal fixing can be
36 - SLCT IN IN
carried out
with DIP SW 1-8. The condition at the time of
shipment
is set "low" for this signal.)
Operation: The printer interface connections with 8255 and the printer
connector in Fig.1.1 and Fig.1.2 respectively. First of all the printer should
be initialised by a 50 S (minimum) pulse on the INIT pin of the printer.
Then BUSY pin is to be to confirm if the printer is ready. If this signal is
low, it indicates that the printer is to accept a character from the CPU. Port
pins of 8255 may not have sufficient drive capacity to drive the printer
input signals so the open collector buffers 74LSOY are used to enhance
the drive capacity. Then the ASCII code of the character to be printed is
sent on the eight parallel port lines. Once the data is sent on eight parallel
lines, the STROBE signal is activated after at least 0.5s, to indicate that
the data is available on the eight data lines. The falling edge of the
STROBE signal causes the printer to make its BUSY pin high, indicating
that the printer is busy. After a minimum period of 0.5S, the STROBE
signal can be sent high. The data must be valid on the data lines for at
least 0.5S after the STROBE signal goes high. After receiving the
appropriate STROBE pulse, the printer starts the necessary
electromechanical action to print the character and when it is ready to
receive the next character, it asserts its ACKNLG signal low
approximately for 5 ms. The rising edge of the ACKNLG signal indicates
to the computer that it is ready to receive the next character. The rising
edge of the ACKNLG signal also resets the BUSY signal from the printer.
A low on the BUSY pin further indicates that the printer is ready to accept
the next character. The ACKNLG and BUSY signals can be used
interchangeably for handshaking purposes. The waveforms for the above
printer operation are shown in Fig.1.3
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 0 0 1 0 A2H
24
D0 Port C lower O/P port D4 Port A O/P port
D1 Port B bit I/P port
D5 D6 Group A in mode 1
D2 Port B mode 0
D7 I/O mode
D3 Port C upper dont care
Strobed I/O mode control word
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 1 0 1
D0 Set to enable D4 Port A O/P port
25