Comprehensive Guide to 8255 PPI and ADC/DAC Interfacing with 8086 Microprocessor
Detailed overview of 8255 Programmable Peripheral Interface modes, ADC 0808/0809 and DAC AD7523 interfacing, stepper motor control, and assembly programming for 8086 microprocessor applications.
Comprehensive Guide to 8255 PPI and ADC/DAC Interfacing with 8086 Microprocessor
1.
8255PROGRAMMABLE PERIPHERAL
INTERFACE(PPI)
For mostof the applications 8086 needs parallel input ,output data
to/from the peripherals.
8255 is a device used to interface different real time peripherals to
the microprocessors which can be initialized for different modes
operations like simple I/O, Strobed I/O and handshaking I/O.
It has three 8-bit parallel ports :port A, port B, port C
Fig 4.3 ControlWord Register Bit Format of 8255 for I/O mode and BSR
mode
7.
Programming 8255
Mode0:
— Ports A, B, and C can be individually programmed as input or output ports
— Port C is divided into two 4-bit ports which are independent from each other
Mode 1:
— Ports A and B are programmed as input or output ports
— Port C is used for handshaking
PA[7:0]
STBA
IBFA
INTRA
PC3
PC5
PC4
PB[7:0]
STBB
IBFB
INTRB
PC0
PC1
PC2
PC6, 7
8255
PA[7:0]
OBFA
ACKA
INTRA
PC3
PC6
PC7
PB[7:0]
OBFB
ACKB
INTRB
PC0
PC1
PC2
PC4, 5
8255
Fig 4.4 Input and Output control signals of 8255 in
mode1
8255: MODE 1INPUT EXAMPLE.
• Keyboard encoder debounces the key-switches,
and provides a strobe whenever a key is
depressed.
• DAV is activated on a key press strobing the ASCII-
coded key code into Port A.
11.
THE DIAGRAM BELOWSHOWS THE
CONNECTION BETWEEN THE 8255 AND A
PRINTER.
12.
Fig 4.5 Inputand Output control signals of 8255 in
mode1
8255 : Mode 1 Input operation
Programming 8255
Mode2:
— Port A is programmed to be bi-directional
— Port C is for handshaking
— Port B can be either input or output in mode 0 or mode 1
PA[7:0]
OBFA
ACKA
INTRA
PC4
PC6
PC7
STBA
IBFA
PC0
PC3
PC5
8255
PC1
PC2
PB[7:0]
In Out
In Out
In Out
Mode 0
STBB OBFB
IBFB ACKB
INTRB INTRB
Mode 1
Fig 4.6 Input and Output control signals of 8255 in mode2
15.
Fig 4.7 Inputand Output control signals
of 8255 in mode2
DISPLAY INTERFACE
Interface an8255 with 8086 at 80h as an I/O address of port-A.
interface five 7 segment displays with the 8255. write a sequence of
instructions to display 1,2,3,4 and 5 over the five displays
continuously as per their positions starting with 1 at the least
significant position. CWR address is 86h.(common anode)
Number to be
displayed
PA7
dp
PA6
a
PA5
b
PA4
c
PA3
d
PA2
e
PA1
f
PA0
g
Code
1 1 1 0 0 1 1 1 1 CF
2 1 0 0 1 0 0 1 0 92
3 1 0 0 0 0 1 1 0 86
4 1 1 0 0 1 1 0 0 CC
5 1 0 1 0 0 1 0 0 A4
All these codes are stored in a look up table starting at 2000:0001.
ALP for displayinterface
again: mov cl,05h ;count for displays
mov bx,2000h ;initialize the data segment for
mov ds,bx ; look-up table
mov ch,01h ;1st
no. to be displayed
mov al,80h
out 86h,al ;load control word in the CWR
mov dl,01h ;enable code for least significant 7-seg
display
nxtdgt: mov bx,0000h ;set pointer to look-up table
mov al,ch ;store number to be display
xlat ;find code from table
24.
out 80h,al
mov al,dl
out82h,al ;enable the display
rol dl,1 ;go for next digit display
inc ch
dec cl ;decrement counter
jnz nxtdgt ;go for next digit display
jmp again
25.
ADC INTERFACING
• Thetime taken by the ADC from the active edge of SOC pulse
till the active edge of EOC signal is called as the conversion
delay of the ADC.
• General algorithm for ADC interfacing contains the following
steps
1. Ensure the stability of analog input, applied to the ADC
2. Issue start of conversion SOC pulse to ADC
3. Read end of conversion EOC signal to mark the end of conversion process
4. Read digital data output of the ADC as equivalent digital output.
26.
ADC 0808/0809
• Theanalog to digital converter chips 0808 and 0809 are 8-bit
CMOS, successive approximation converters. It is fastest technique.
• The conversion delay is 100 µs at a clock frequency of 640 kHz,
which is quite low as compared to other converters.
Block Diagram of ADC 0808/0809
• This converter internally has a 3:8 analog multiplexer, so that at a
time 8 different analog inputs can be connected to the chips.
• Out of these 8 inputs only one can be selected for conversion by
using 3 address lines A,B,C.
• The CPU may drive these lines using output port lines in case of
multichannel applications.
• THESE AREUNIPOLAR ANALOG TO DIGITAL (A TO D)
CONVERTERS,THEY ARE ABLE TO CONVERT ONLY POSITIVE
ANALOG INPUTVOLTAGES TOTHEIR DIGITAL EQUIVALENTS.
THIS CHIPS DO NOT CONTAIN ANY INTERNAL SAMPLE &
HOLD CIRCUIT.
Table 4.1 analog input selection
29.
INTERFACING BETWEEN ADCTO MICROPROCESSOR
Problem:-
Interface ADC 0808 with 8086 using 8255 ports. Use
Port A of 8255 for transferring digital data output of ADC to
the CPU & 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 &
timing diagram of different signals of ADC0808.
30.
Solution:-
• The analoginput I/P2 is used & therefore address pins A,B,C
should be 0,1,0 respectively to select I/P2.
• The OE (Out put latch Enable) & 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
ADC.
• Port A acts as a 8-bit input data port to receive the digital data
output from the ADC.
31.
8255 Control Word:
D7D6 D5 D4 D3 D2 D1 D0
1 0 0 1 1 0 0 0 = 98H
Program:
MOV AL,98H ; Initialize 8255, send AL to control word (CWR)
OUT 86H, AL
MOV AL, 02H ;Select I/P2 as analog I/P
OUT 82H, AL ;Port B as output
MOV AL, 01H ; Give start of conversion pulse to the ADC
OUT 84H, AL
MOV AL, 00H
OUT 84H, AL
WAIT: IN AL, 84H ; check for EOC by reading Port C upper & rotating
RCL AL,1 ; through carry.
JNC WAIT
IN AL, 80H ; if EOC, read digital equivalent in AC
HLT ; stop.
INTERFACING D/A CONVERTERS
•The Digital to Analog Converters (DAC) convert binary
numbers into their analog equivalent voltages.
• The DAC find applications in areas like
• Digitally controlled gains
• Motor speed controls
• Programmable gain amplifiers etc.
AD 7523 8-Bit Multiplying DAC:--
• Intersil’s AD 7523 is a 16 pin DIP, multiplying digital to analog converter, containing R-2R ladder
(R=10K) for digital to analog conversion.
34.
Power supply +5vto +15v
Vref -> -10v to +10v
The maximum analog output voltage will be +10v
A Zener is connected between OUT1 & OUT2 to save the
DAC from negative transients.
An operational amplifier is used as a current – to – voltage
converter at the output of AD 7523.
An external feedback resister acts to control the gain.
35.
Interfacing of AD7523 with 8086
Problem:--
Interface DAC AD7523 with the 8086 running at 8MHz & write
ALP to generate a saw tooth waveform of period 1ms with
Vmax =5v.
Solution:--
PROGRAM1:
Code segment
Assume cs: code
Start: MOV AL, 80H
OUT F6H, AL
AGAIN: MOV AL, 00H
BACK: OUT F0H, AL
INC AL
CMP AL, 0F2H
JB BACK
JMP AGAIN
Code ends
End Start
PROGRAM2:
MOV DX, 0FFE6
MOV AL, 80H
OUT DX,AL
MOV DX, 0FFE0
MOV AX, 00 H
RPT: MOV CX, 0FF
L1: OUT DX, AX
INC AX
LOOP L1
MOV AX, 00 H
OUT DX, AX
JMP RPT
INTERFACING D/A CONVERTERS
•GENERATION OF WAVE FORMS:
• programs to generate the following wave forms:
• Triangular wave forms
• Saw tooth wave forms
• Square wave
39.
PROGRAM (FOR SAWTOOTHWAVE):
MOV DX, 0FFE6H
MOV AL, 80H
OUT DX,AL
MOV DX, 0FFE0H
MOV AL, 00 H
RPT: MOV CL, 0FFH
L1: OUT DX, AL
INC AL
LOOP L1
MOV AL, 00 H
OUT DX, AL
JMP RPT
40.
PROGRAM (FOR SQUAREWAVE):
MOV DX, 0FFE6H
MOV AL, 80H
OUT DX, AL
MOV DX, 0FFE0 H
RPT: MOV AL, 0FFH
OUT DX, AX
CALL DELAY
MOV AL, 00H
OUT DX, AL
CALL DELAY
JMP RPT
DELAY PROGRAM:
MOV CL, 1EH
L1: NOP
NOP
LOOP L1
RET
41.
MOV DX, 0FFE6H
MOVAL, 80 H
OUT DX, AL
MOV DX, 0FFE0H
MOV AL, 00 H
RPT: MOV CL, 0FFH
L1: OUT DX, AL
INC AL
LOOP L1
MOV CL, 0FFH
L2 : OUT DX,AL
DEC AL
LOOP L2
JMP RPT
PROGRAM (FOR TRIANGULAR WAVE):
42.
STEPPER MOTOR INTERFACING
•A stepper motor is a device used to obtain an accurate position control
of rotating shafts.
• It employs rotation of its shaft in terms of steps, rather than continuous
rotation as in case of AC or DC motors.
• In dot-matrix printer one small stepper motor which is used to advance
the paper to the next line position & another small stepper motor which
is used to move the print head to the next character position.
• In floppy disk stepper motor is used to position the read/write head over
the desired track.
• To rotate the shaft of the stepper motor, a sequence of pulses is needed
to be applied to the windings of the stepper motor, in a proper sequence.
• The no. 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.
43.
• The statorteeth 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 = 3600
/ no. of rotor teeth
• The stepper motors have been designed to work with digital
circuits. Binary level pulses of 0-5v are required at its winding inputs
to obtain the rotation of shafts.
• The sequence of pulses can be decided, depending upon the
required motion of the shaft.
• The count for rotating the shaft of the stepper motor through a
specified angle may be calculated from the no. of rotor teeth
C = no. of rotor teeth / 3600
* θ0
44.
Motion Step AB 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
Anticlockwise 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
Table 4.2 Excitation sequence for clockwise and anticlockwise rotation of a
stepper motor
45.
Problem
Design a steppermotor controller and write an ALP to rotate shaft of a
4-phase stepper motor:
i. In clockwise 5 rotations
ii. In anticlockwise 5 rotations.
The 8255 port A address is 0740h.The stepper motor has 200 rotor
teeth.
The port A bit PA0 drives winding Wa, PA1 drives windingWb and so on.
The stepper motor has an internal delay of 10msec.Assume that the
routine for this delay is already available.
46.
Solution:
MOV DX, 0FFE6
MOVAL, 80
OUT DX, AL
RPT: MOV BX,07D0 H
MOV DX, 0FFE0
MOV AL, 11
BACK: OUT DX, AL
MOV CX, 0300H
L1: LOOP L1
ROL AL, 1 ; Anticlockwise
DEC BX
JNZ BACK