INTERFACING
INTERFACING
Group A
Port C Upper PC7-PC4
1 = input, 0 = output
Port A
1 = input, 0 = output
Mode Selection
00 = Mode0, 01 = Mode1
1x = Mode 2
1 = I / O Mode
0 = BSR Mode
8255 Design Example
D0 D0
A
D7 D7
B
IOW WR
IOR RD
CL
A2 A0 A0
System A1 A1 CH
Address Bus CS
A7
Interface DAC to a CPU
• DAC (Digital-to-Analog Converter)
– Device used to convert digital pulses to analog
signals
– Two methods of making the DAC
• Binary weighted
• R / 2R ladder
• The vast majority of IC use R / 2R since it can achieve a
much high degree of precision
Criterion for Judging a DAC: Resolution
• Resolution is a function of the number of
binary inputs. common ones are 8, 10, 12
pins
• The number of analog output levels is equal to
2n, where n is the number of data inputs
8-input DAC (MC1408)
gives 256 discrete voltage/current levels of output
12-input DAC 4096 voltage/current levels
16-input DAC 65,536 voltage/current levels
MC1480 DAC (or DAC 808)
• In MC1480, the digital inputs are converted to
current (Iout) and by connecting a resister to the
Iout pin, we convert the result to voltage.
• The current provided by Iout is a function of binary
numbers at D0-D7 and the reference current.
• Iref is generally set to 2.0 mA.
• Iout = Iref . (D7/2 + D6/4 + D5/8 + D4/16 + D3/32 +
D2/64 + D1/128 + D0/256).
Interface DAC to CPU
• Example1
– Interface MC1480 to Microprocessor through PPI
8255
• Example2
– Interface AD558 directly to Microprocessor
Interface MC1480 to
Microprocessor through PPI 8255
+5
1k
1.5k
D0 D0 PA0 A8(LSB) Vref(+)
... ... . . .
. . .
D7 D7 2.5k
. . . Vref(-)
. . .
IOW WR
PA7 A0(MSB) To Scope
IOR RD
8255 Vout = 0 - 10v
MC1480
A0 A0
COMP R = 5k
A1 A1
A2 100 pf
... Decoding
A9 CS VEE
AEN
Circuitry RESET GND
-12 v
VCC
MOV AL, 80H
OUT PCtrl, AL Imax = 1.99 mA
MOV AL, 0 Vmax = 9.95 V
Cont: OUT PA, AL 9.95 v
INC AL
CMP AL, 0
JZ Stop
MOV CX, 0FFFFH
Here: LOOP Here
0v
JMP Cont
Stop: INT 6
• LED is directly connected to the microcontroller. The
negative terminal of the LED is connected to the
ground through a resistor. Value of this resistor is
calculated using the following formula.
R= (V-1.7)/10mA,
where V is the input voltage.
• Generally, microcontrollers output a maximum
voltage of 5V. Thus the value of resistor calculated for
this is 330 Ohms. Thus this can be connected either
to the cathode or anode of the LED.
8051 - Switch On I/O Ports
• Case-1:
– Gives a logic 0 on switch close
– Current is 0.5ma on switch close
• Case-2:
– Gives a logic 1 on switch close
– High current on switch close