SlideShare ist ein Scribd-Unternehmen logo
1 von 42
ACOE255 1
Microprocessors
Input/Output Interface
(Chapter 10)
ACOE255 2
Introduction
• In a typical computer system, the user communicates with the computer via
standard peripheral devices such as the keyboard, mouse, display, printer e.t.c.
• Furthermore computers and microprocessor based systems are used in
instrumentation or automatic control applications. In such cases it is necessary
that the microprocessor reads the state of input devices (switches, sensors) and
activate some output devices (motors, heaters, lights).
• The I/O interface is required to enable the interface between the microprocessor
and the peripheral devices.
• The peripheral devices are connected on a microprocessor system through the
Input/Output ports.
• The I/O interface provides the following:
– Isolation between the buses and the peripheral devices.
– Address decoding.
– Synchronization/Latching.
ACOE255 3
Isolated vs Memory-mapped I/O
• Isolated I/O
– I/O locations are separate from memory locations
– Special I/O instructions are used
– The most common technique for Intel microprocessors
– Advantage: More space for memory
– Disadvantage: Additional control signals (IO/M) and instructions increase complexity
• Memory-mapped I/O
– I/O devices are treated as memory locations in the memory map
– Any memory transfer instruction can be used (MOV, LDR, STR etc)
– Advantages: Simpler decoding circuitry, no special instructions required
– Disadvantage: A portion of the memory system is used as the I/O map, reducing the
memory available to applications
ACOE255 4
Input/Output Instructions
• The 8088 and 80X86 processors use the 16 lower address lines (A0 to A15) to
address I/O devices. This limits the maximum number of I/O ports to 64K.
• The IN instruction copies the content of an input port to register AL, AX or EAX.
• The OUT instruction copies the content of register AL, AX, or EAX to an output
port.
• Register AL is used for 8-bit ports, AX for 16-bit ports and EAX for 32-bit ports.
• The 8088 and 80X86 processors support two I/O addressing modes.
– Fixed Address. The address is directly specified in the instruction as an 8-bit number.
That is loaded on the address lines A0 to A7. Address lines A8 to A15 are set to 00.
• IN AL,30H ;Read input port 0030H into register AL
• OUT 30H,AL ;Copy register AL to output port 0030H.
– Variable Address. The address is specified through register DX as a 16-bit address.
• MOV DX,3A0H ;Set I/O address
• IN AL,DX ;Read input port [DX] or 3A0H into register AL.
• OUT DX,AL ;Copy register AL to output port [DX] or 3A0H
ACOE255 5
High Level Language Input/Output Instructions (Pascal)
• Input/Output using Pascal: I/O is obtained using the ‘Port[ ]’ instruction.
– X := Port[PortAddress]; /* Copy the contents of the specified port into X */
– Port[PortAddress] := X; /* Copy the contents of X into the specified port */
• Input/Output using Delphi: Delphi does not allow direct access to I/O ports.
This can be done by inserting assembly language code into Delphi as follows:
asm ; code equivalent to ‘value:=port[portaddress];
begin
mov dx,portaddress ;specify the port address
in al,dx ;input from the port specified by “dx” into “al”
mov value,al ;copy input data into variable ‘value’
end;
asm ; code equivalent to ‘port[portaddress] := value;
begin
mov dx,portaddress ;specify the port address
mov al,value ;move output data into register “al”
out dx,al ;output data to the port specified by “dx”
end;
ACOE255 6
High Level Language Input/Output Instructions (C/C++)
• C/C++ does not allow direct access to I/O ports. This can be done by inserting
assembly language code into the C/C++ code as follows:
__asm ; code equivalent to ‘value:=port[portaddress];
{
mov dx,portaddress ;specify the port address
in al,dx ;input from the port specified by “dx” into “al”
mov value,al ;copy input data into variable ‘value’
}
__asm ; code equivalent to ‘port[portaddress] := value;
{
mov dx,portaddress ;specify the port address
mov al,value ;move output data into register “al”
out dx,al ;output data to the port specified by “dx”
}
ACOE255 7
Input/Output Using DLLs (C/C++)
• For protection purposes, modern operating systems such as the Windows XP do
not allow the use of the IN and the OUT instructions in the users programs.
• A way to have access to I/O ports is through libraries (DLL files) developed for
this purpose. Such a library is the inout32.dll
• To use this library in Visual Studio (C++) we must:
– Add the inout32.lib file in the Linker properties
• Project ->Properties->Linker->Input->Additional Dependencies
– Define the two functions for input and output and use them accordingly
short _stdcall Inp32(short PortAddress);
void _stdcall Out32(short PortAddress, short data);
main()
{
short Inval = Inp32(889); /* input from port 889 into variable “Inval”*/
Out32(888,0x2f); /* Output the hex value 2f to port 888 */
}
ACOE255 8
Simple Input Port
• An input port can be implemented
using a simple octal buffer such as
the 74LS244.
• The address decoding circuit
enables the three-state buffers of
the 74LS244 whenever the port
address is selected by the
processor. In such a case the state
of the input devices appears on the
data bus.
• The address decoding circuit is
enabled only if the IO/M signal is
set High by the 8088 (Low for the
x86 processors) and the RD signal
is Low.
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
LS244
G1 G2
A11
A10
A9
A8
A7
A6
A5
A4
A11A10 A9 A8 A4
A7 A6 A5 A1
A3 A2 A0
0 1 0 0 0
0 1 1 X
X X X
Address
460H to 46FH
Switch Open => Logic 1
Switch Closed => Logic 0
ACOE255 9
Simple Output Port (Using the 74LS373)
• An output port can be implemented
using a simple octal latch such as
the 74LS373.
• The address decoding circuit
enables the D-latches of the
74LS373 whenever the port
address is selected by the
processor. In such a case the state
of the data bus is latched to the
output devices.
• The address decoding circuit is
enabled only if the IO/M signal is
set High by the 8088 (Low for the
x86 processors) and the WR signal
is Low.
LS373
D Q
EN
EN OE
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
A11
A10
A9
A8
A7
A6
A5
A4
A11A10 A9 A8 A4
A7 A6 A5 A1
A3 A2 A0
0 1 0 0 0
0 1 1 X
X X X
Address
460H to 46FH
Logic 1 => LED is OFF
Logic 0 => LED is ON
ACOE255 10
Simple Output Port (Using the 74HCT573)
• The 74HCT573 is pin compatible
with the 74LS373. There are three
significant differences:
– The ‘573 has all inputs on the left side and
all outputs on the right side of the IC,
while the ‘373 has the even numbered
inputs on the left side and the odd
numbered inputs on the right side. Thus
the ‘573 is easier to by handled on PCB
boards.
– The HCT573 has a 20mA current sink and
a 20mA current source, thus it can drive a
LED connected either to the ground or to
+5V. The LS373 has a 16mA current sink
and a 400uA current source, thus it can
only drive a LED connected to +5V.
– The HCT family is faster than the LS
family.
HCT573
D Q
EN
EN OE
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
A11
A10
A9
A8
A7
A6
A5
A4
A11 A10 A9 A8 A4
A7 A6 A5 A1
A3 A2 A0
1 0 0 0 1
0 1 0 X
X X X
Address
850H to 85FH
+5V
Logic 1 => LED is OFF
Logic 0 => LED is ON
Logic 1 => LED is ON
Logic 0 => LED is OFF
ACOE255 11
Simple I/O Example 1 (Hardware)
• Draw a circuit to show how 8 switches can be connected on the input port 3AH
and 8 LEDs on the output port 5CH.
ACOE255 12
Simple I/O Example 1 (Software)
Write a program to keep reading the state of the switches and switch ON the LED
at the position form by the switches at D2, D1 and D0 (i.e. 3X8 decoder).
Pseudo Code:
Repeat
Read Input port in InVal
Mask out D2,D1,D0 from InVal
if InVal = 0 then OutVal = 1
if if InVal = 1 then OutVal = 2
if InVal = 2 then OutVal = 4
if InVal = 3 then OutVal = 8
if InVal = 4 then OutVal = 16
if if InVal = 5 then OutVal = 32
if InVal = 6 then OutVal = 64
if InVal = 7 then OutVal = 128
Write OutVal to Output port
Until keypressed
C/C++ Code
main()
{
short InVal, OutVal = 0;
do { InVal = Inp32(0x3a);
InVal = InVal & 0x7;
if (InVal == 0) OutVal = 0x1;
if (InVal == 1) OutVal = 0x2;
if (InVal == 2) OutVal = 0x4;
if (InVal == 3) OutVal = 0x8;
if (InVal == 4) OutVal = 0x10;
if (InVal == 5) OutVal = 0x20;
if (InVal == 6) OutVal = 0x40;
if (InVal == 7) OutVal = 0x80;
Out32(0x5c,OutVal);
} while (!_kbhit());
}
ACOE255 13
Mask Operations
(a) Write a program to keep reading the
.
(b) Write a program to keep reading the
state of the switches and switch ON
the LEDs for which the corresponding
switch is closed.
ACOE255 14
Simple I/O Example 2
Four float switches and four LEDs are used to indicate the level of a liquid in the tank
shown below. The switches and the LEDs are connected on a computer through an
interface board with an input and an output port occupying the address 460H to 46FH.
• Draw the circuit diagram of the interface board.
• Write a program to keep reading the state of the float switches and display the liquid
level on the LEDs. If an error is detected then switch ON all LEDs.
Interface
Board
Empty
Low
Half
Full
DI3
DI2
DI1
DI0
DO3
DO2
DO1
DO4
Closed
Closed
Open
Open
High
DO0
DI3 DI2 DO3 DO2 DO1
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 1 0 1 1 1
0 0 1 1 0 0 1
0 1 0 0 1 1 1
0 1 0 1 1 1 1
0 1 1 0 1 1 1
0 1 1 1 0 1 0
1 0 0 0 1 1 1
1 0 0 1 1 1 1
1 0 1 0 1 1 1
1 0 1 1 1 1 1
1 1 0 0 1 1 1
1 1 0 1 1 1 1
1 1 1 0 1 1 1
1 1 1 1 1 0 0
DI1 DI0
Empty
Low
Error
Half
Error
Error
Error
High
Error
Error
Error
Error
Error
Error
Error
Full
0 1
1 0
1 1
0 0
1 1
1 1
1 1
0 0
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 0
DO0
DO4 State
ACOE255 15
Simple I/O Example 2 (Circuit Diagram)
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
HCT573
D Q
EN
EN OE
LS244
G1 G2
DI0
DI1
DI2
DI3
DO4
DO3
DO2
DO1
DO0
A11
A10
A9
A8
A7
A6
A5
A4
A11A10 A9 A8 A4
A7 A6 A5 A1
A3 A2 A0
0 1 0 0 0
0 1 1 X
X X X
Address
460H to 46FH
ACOE255 16
Simple I/O Example 2 (Software using Case/Switch Statement)
Pseudo Code:
Set OutVal to 0, i.e switch off all leds
Repeat
Read Input port in InVal
Mask out D3,D2,D1,D0 from InVal
Case of InVal
0: OutMask = 1
1: OutMask = 2
3: OutMask = 4
7: OutMask = 8
FH: OutMask = 10H
else OutMask = 1FH
Mask in D4 to D0 of OutMask in OutVal
Write OutVal to Output port
Until keypressed
C/C++ Code
main()
{
short InVal, OutVal = 0;
do {
InVal = Inp32(0x460);
InVal = InVal & 0xf;
switch (InVal) {
case 0: OutMask = 1; break;
case 1: OutMask = 2; break;
case 3: OutMask = 4; break;
case 7: OutMask = 8; break;
case 0xf: OutMask = 0x10; break;
default OutMask = 0x1f; }
OutVal = (OutVal & 0xe0) | OutMask;
Out32(0x460,OutVal);
} while (!_kbhit());
}
ACOE255 17
Simple I/O Example 2 (Software using array as a lookup table)
Pseudo Code:
Table[0] = 00001 /*
Table[1] = 00010 /*
Table[3] = 00100 /*
Table[7] = 01000 /*
Table[15] = 10000 /*
Table[rest] = 111111 /*
Repeat
Read Input port in InVal
Mask out D2,D1,D0 from InVal
Mask in D2,D1,D0 of Table[InVal] to OutVal
Write OutVal to Output port
Until keypressed
C/C++ Code
main()
{
short InVal, OutVal = 0;
short Table[16] = 0x1, 0x2, 0x1f, 0x4,
0x1f, 0x1f, 0x1f, 0x8,
0x1f, 0x1f, 0x1f, 0x1f,
0x1f, 0x1f, 0x1f, 0x10;
do {
InVal = Inp32(0x460);
InVal = InVal & 0xf;
OutMask = Table[InVal];
OutVal = (OutVal & 0xe0) | OutMask;
Out32(0x460,OutVal);
} while (!_kbhit());
}
ACOE255 18
DC Motor Speed and Direction Control
• The speed of a DC motor is proportional to the DC voltage applied at its
terminal.
– Thus the speed can be controlled by controlling the DC voltage.
• The DC voltage can be controlled by:
– Inserting a resistor in series with the DC motor.
• Unnecessary dissipation of energy on the resistor.
– Using Pulse Width Modulation (PWM)
• The direction of rotation a DC motor is reversed by reversing the polarity of the
DC voltage applied at its terminal.
– This can be obtained using a relay (change-over connection).
– Connecting a relay on an output port requires the use of high current drivers such as
the ULN2803 and diodes to protect the output transistors due to Lenz’s law.
• Special drivers (H-drivers) can also be used to provide both speed control and
direction control.
Average Voltage
ACOE255 19
DC motor interface example
A DC motor is connected to a computer as shown below. The switches and the
motor are connected on an input and an output port occupying the address
460H to 46FH.
• Draw a circuit of the interface and the connections to the motor
• Write a program to keep reading the state of the switches and control the
operation of the motor accordingly.
0
1
0
1
0
1
Start/Stop Fast/Slow Fwrd/Rev.
Interface Board
DC Motor
ACOE255 20
DC motor interface example(Circuit Diagram)
A11A10 A9 A8 A4
A7 A6 A5 A1
A3 A2 A0
0 1 0 0 0
0 1 1 X
X X X
Address
460H to 46FH
RL
1
ULN2803
Com
RL
2
RL
2
M
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
HCT573
D Q
EN
EN OE
LS244
G1 G2
DI7
DI6
DI5
DI4
DO2
DO1
DO0
A11
A10
A9
A8
A7
A6
A5
A4
On/Off
Fast/Slow
Frwd/Rev.
+5V
+5V
+5V
DI3
DI2
DI1
DI0
ACOE255 21
DC motor interface example (Software using conditional execution)
Pseudo Code:
Set OutVal to 0, i.e motor is OFF
Repeat
Read Input port in InVal
If On/Off bit = 1 then OutVal(D0) = 1
else OutVal(D0) = 0
If Fast/Slow bit = 1 then OutVal(D1) = 1
else OutVal(D1) = 0
If Frwd/Rev bit = 1 then OutVal(D2) = 1
else OutVal(D2) = 0
Write OutVal to Output port
Until keypressed
ACOE255 22
DC motor interface example (Software using a lookup table)
Pseudo Code:
Table[0] = 000 /* 000 ->motor is Off
Table[1] = 000 /* 001 ->motor is Off
Table[2] = 010 /* 010 -> On-Slow-Rev
Table[3] = 011 /* 011 -> On-Slow-Frwd
Table[4] = 000 /* 100 -> motor is Off
Table[5] = 000 /* 101 -> motor is Off
Table[6] = 110 /* 110 ->On-Fast-Rev
Table[7] = 111 /* 111 ->On-Fast-Frwd
Repeat
Read Input port in InVal
Mask out D2,D1,D0 from InVal
Mask in D2,D1,D0 of Table[InVal] to OutVal
Write OutVal to Output port
Until keypressed
ACOE255 23
7-Segment Displays
• Used to display the digits from 0 to 9, as well as many letters (A,b,C,d,E,F,L,H)
• Consists of seven leds connected to a common point
• Can be common-anode or common-cathode
a
b
c
d
e
f
g
a
b
c
d
e
f
g
a b c d e f g
a b c d e f g
+Vcc
0: OFF
1: ON
0: ON
1: OFF
Common Cathode Common Anode
Can be connected directly on an O/P port Through a BCD/7 segment decoder
OR
HCT573
D Q
EN
EN OE
DO4
DO3
DO2
DO1
DO0
DO5
DO6
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
HCT573
D Q
EN
EN OE
DO4
DO3
DO2
DO1
DO0
DO5
DO6
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
CD4511
D
OE
A
/LE
C
B
D
/BL
/LT
EN
Q
Latch
BCD-7seg
decoder
Buffer
ACOE255 24
7-segment Displays – Example1
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
HCT573
D Q
EN
EN OE
LS244
G1 G2
DI0
DI1
DI2
DI3
DO4
DO3
DO2
DO1
DO0
A11
A10
A9
A8
A7
A6
A5
A4
DO5
DO6
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
x 0 1 1 1 1 1 1 3F
x 0 0 0 1 1 0 0 0C
x 1 1 1 0 1 1 0 76
x 1 0 1 1 1 1 0 5E
x 1 0 0 1 1 0 1 4D
x 1 0 1 1 0 1 1 5B
x 1 1 1 1 0 1 1 7B
x 0 0 0 1 1 1 0 0E
x 1 1 1 1 1 1 1 7F
x 1 0 0 1 1 1 1 4F
x 1 1 0 1 1 1 1 6F
x 1 1 1 1 0 0 1 79
x 0 1 1 0 0 1 1 33
x 1 1 1 1 1 0 0 7C
x 1 1 1 0 0 1 1 73
x 1 1 0 0 0 1 1 63
- g f e d c b a
D0
D1
D2
D3
D4
D5
D6
D7
• Draw a circuit to show how a common cathode 7-segment display can be
connected on an o/p port and four switches on an i/p port both occupying the
address range 860h to 86Fh.
• Write a program to read the state of the switches and display the binary number
formed by the switches as a hexadecimal digit.
ACOE255 25
7-segment Displays – Example1: Program
ACOE255 26
7-Segment Displays: Example 2
Four float switches and a 7-segment display are used to indicate the level of a liquid in the
tank shown below. The switches and the display are connected on a computer through an
interface board with an input and an output port occupying the address 460H to 46FH.
Draw the circuit diagram of the interface board.
Write a program to keep reading the state of the float switches and display the liquid level
on the display using the digits F(Full), H(High), A (Half), L(Low) and E(Empty). If an error
is detected then switch ON the decimal point.
Interface
Board
DI3
DI2
DI1
DI0
DO3
DO2
DO1
DO4
DO0
DO6
DO5
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
dp
Open
Open
Closed
Closed
DI3 DI2
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
DI1 DI0
Empty
Low
Error
Half
Error
Error
Error
High
Error
Error
Error
Error
Error
Error
Error
Full
State
E
L
.
A
.
.
.
H
.
.
.
.
.
.
.
F
Digit Code
ACOE255 27
7-segment Displays – Example1: Program
ACOE255 28
7-segment Displays – Example3
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
HCT573
D Q
EN
EN OE
LS244
G1 G2
DI0
DI1
DI2
DI3
DO4
DO3
DO2
DO1
DO0
A11
A10
A9
A8
A7
A6
A5
A4
DO5
DO6
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
x 0 1 1 1 1 1 1 3F
x 0 0 0 1 1 0 0 0C
x 1 1 1 0 1 1 0 76
x 1 0 1 1 1 1 0 5E
x 1 0 0 1 1 0 1 4D
x 1 0 1 1 0 1 1 5B
x 1 1 1 1 0 1 1 7B
x 0 0 0 1 1 1 0 0E
x 1 1 1 1 1 1 1 7F
x 1 0 0 1 1 1 1 4F
x 1 1 0 1 1 1 1 6F
x 1 1 1 1 0 0 1 79
x 0 1 1 0 0 1 1 33
x 1 1 1 1 1 0 0 7C
x 1 1 1 0 0 1 1 73
x 1 1 0 0 0 1 1 63
- g f e d c b a
D0
D1
D2
D3
D4
D5
D6
D7
• Draw a circuit to show how a common cathode 7-segment display can be
connected on an o/p port and four switches on an i/p port both occupying the
address range 860h to 86Fh.
• Write a program to read the state of the switches and display the binary number
formed by the switches as a hexadecimal digit.
ACOE255 29
7-segment Displays– Example1: Program
ACOE255 30
7-segment Displays– Example1
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
HCT573
D Q
EN
EN OE
LS244
G1 G2
DI0
DI1
DI2
DI3
DO4
DO3
DO2
DO1
DO0
A11
A10
A9
A8
A7
A6
A5
A4
DO5
DO6
DO7
a
b
c
d
e
f
g
a
b
c
d
e
f
g
x 0 1 1 1 1 1 1 3F
x 0 0 0 1 1 0 0 0C
x 1 1 1 0 1 1 0 76
x 1 0 1 1 1 1 0 5E
x 1 0 0 1 1 0 1 4D
x 1 0 1 1 0 1 1 5B
x 1 1 1 1 0 1 1 7B
x 0 0 0 1 1 1 0 0E
x 1 1 1 1 1 1 1 7F
x 1 0 0 1 1 1 1 4F
x 1 1 0 1 1 1 1 6F
x 1 1 1 1 0 0 1 79
x 0 1 1 0 0 1 1 33
x 1 1 1 1 1 0 0 7C
x 1 1 1 0 0 1 1 73
x 1 1 0 0 0 1 1 63
- g f e d c b a
D0
D1
D2
D3
D4
D5
D6
D7
• Draw a circuit to show how common cathode 7-segment display can be
connected on an o/p port and four switches on an i/p port both occupying the
address range 860h to 86Fh.
• Write a program to read the state of the switches and display the binary number
formed by the switches as a hexadecimal digit.
ACOE255 31
Homework- Question 1
a) Draw a circuit diagram to show how four switches and two 7-segment displays
can be interfaced to an 8088 based system occupying the address 10H to
1FH, 20H to 2FH and 30H to 3FH respectively.
b) Write a program to read the binary number formed by the four switches and
display the equivalent decimal number on the 7-segment displays. For
example if the switches form the number 0110, the displays should display the
number 06, and if the switches form the number 1110, then the displays should
display the number 14.
ACOE255 32
a) Draw a circuit diagram to show how four switches and a 7-segment display can
be interfaced to an 8088 based system occupying the address A0H to AFH,
F0H to FFH respectively.
b) Write a program to read the state of the switches and display on the 7-segment
display the letter:
• H, if there are more switches closed than open,
• L, if there are less switches closed than open,
• E, if the number of switches closed is equal to the number of switches open.
Homework- Question 2
ACOE255 33
a) Draw a circuit diagram to show how six switches and eight Leds can be
interfaced to an 8088 based system occupying the address 30H to 3FH, 20H to
2FH respectively.
b) Write a program to read the binary number formed by the six switches and
display the equivalent Binary Coded Decimal number on the Leds. For
example if the switches form the number 100101, the displays should display
the number 00110111, since (100101)2 = (00110111)BCD.
Homework- Question 3
ACOE255 34
a) Draw a circuit diagram to show how the following can be interfaced to an 8088
based system:
i. Four switches connected on an I/P port occupying the address range from 30H to
3FH.
ii. Eight Leds connected on an O/P port occupying the address range from 20H to
2FH.
b) Write a program to read the BCD number formed by the four switches, and
display it on the eight Leds the square of the input number in BCD form. If the
number formed by the switches is an invalid BCD number, then all of the Leds
should be switched ON.
– For example if the switches form the number 00000101 then the Leds should
display 00100101, since (00000101)BCD = (05)10 and 52 = 25 = (00100101)BCD
– If the number formed by the switches is 00001100 then the Leds should display
11111111 since 1100 is an invalid BCD number.
Homework- Question 4
ACOE255 35
a) Draw a circuit diagram to show how a common cathode 7-segment display can
be connected on an output port, occupying the address CAH.
b) Write a program to display the digits from 0 to 9 on the 7-segment display with
a 1-second delay between digits.
c) Write a procedure to display on the 7-segment display, the letter E if the
contents of the variable INVAL is equal to 80H, the letter H if INVAL is greater
than 80H, or the letter L if INVAL is less than 80H.
d) Write a program that keeps reading the binary number from the input port
0AAH and displays on the 7-segment display, a letter according to the table
given below.
Homework- Question 5
xxxxx000 xxxxx001 xxxxx010 xxxxx011 xxxxx100 xxxxx101 xxxxx110 xxxxx111
E I L U H Γ Ξ F
ACOE255 36
a) Draw a circuit diagram to show how the following can be interfaced to an 8088 system
i. Three switches connected on an I/P port occupying the address range from 60H to 6FH.
ii. Eight Leds connected on an O/P port occupying the address range from 50H to 5FH.
b) Write a program to
i. read the code formed by the three switches in a 1-second time intervals,
ii. convert the input code into a binary value according to the table below and store it in an array
called BINV, and
iii. display it as a bar graph on the eight Leds as shown in figure below
For example if the switches form the number 101 then the number 110 must be stored in the
array BINV and the Leds should display 11111110.
0 0 0
0 0 0
0 0 1
0 0 1
0 1 0
0 1 1
0 1 1
0 1 0
1 0 0
1 1 0
1 0 1
1 0 0
1 1 0
1 0 1
1 1 1
1 1 1
Input Binary Bar Graph
Homework- Question 6
ACOE255 37
THE 82C55 PROGRAMMABLE PERIPHERAL INTERFACE (PPI)
VCC: The +5V power supply pin.
GND: GROUND
D0-D7: I/O DATA BUS
RESET: A high on this input clears the control register and all ports
(A, B, C) are set to the input mode with the “Bus Hold” circuitry
turned on.
CS: Chip select is an active low input used to enable the 82C55A onto
the Data Bus for CPU communications.
RD: Read is an active low input control signal used by the CPU to
read status information or data via the data bus.
WR: Write is an active low input control signal used by the CPU to
load control words and data into the 82C55A.
A0-A1: Address input signals, in conjunction with the RD and WR
inputs, control the selection of one of the three ports or the control
word register (00 – Port A, 01 – Port B, 10 – Port C, 11 – CR).
PA0-PA7 (I/O PORT A): 8-bit input and output port.
PB0-PB7 (I/O PORT B): 8-bit input and output port.
PC0-PC7 (I/O PORT C): 8-bit input and output port.
•A popular interfacing component, for interfacing TTL-compatible I/O devices to the microprocessor.
•Requires insertion of wait states if used with a microprocessor using higher that an 8 MHz clock.
•PPI has 24 pins for I/O that are programmable in groups of 12 pins and three modes of operation
(Basic I/O, Strobed I/O, Strobed Bi-directional Bus I/O).
•In the PC, an 82C55 or its equivalent is decoded at I/O ports 60H-63H, interfacing keyboard and
Parallel printer port).
ACOE255 38
INTERFACING 82C55 TO AN 8088 SYSTEM (ports 60H-63H)
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
DI0
DI1
DI2
DI3
A7
A6
A5
A4
A3
A2
82C55
D7
D0
RD
WR
A0
A1
PA7
PA0
PB7
PB0
PC7
PC0
CS
A0
A1
ACOE255 39
EXAMPLE
• Use a 82C55 PPI to interface four switches at address 60H
and a SSD at address 62H
A19
D7
D0
RD
WR
IO/M'
8088
System
A0
+5V
DI0
DI1
DI2
DI3
A7
A6
A5
A4
A3
A2
a
b
c
d
e
f
g
a
b
c
d
e
f
g
82C55
D7
D0
RD
WR
A0
A1
PA7
PA0
PB7
PB0
PC7
PC0
CS
A0
A1
DI0
DI1
DI2
DI3
DI0
DI1
DI2
DI3
ACOE255 40
PROGRAMMING THE 82C55
• Mode 0 operation causes the PPI to function as either buffered input or latched
output
• The 82C55 is programmed through two internal command registers, selected
through bit 7.
• Command byte A
– 0 Port C, PC3-PC0 (1-input, 0-output)
– 1 Port B (1-input, 0-output)
– 2 Mode (00-mode 0, 01-mode1)
– 3 Port C, PC7-PC4 (1-input, 0-output)
– 4 Port A (1-input, 0-output)
– 5-6 Mode (00-mode 0, 01-mode 2, 1X-mode 2)
– 7 Command byte select (always 1 for Command byte A)
• Command byte B
– Used in mode 1 and mode 2
ACOE255 41
Example
• Rewrite the program of the example of slide 30, this time using the PPI and
setting up the ports as shown in the previous slide
ACOE255 42
Homework
• All examples of slides 31-36 can be modified to include PPI interfacing

Weitere ähnliche Inhalte

Ähnlich wie knowledge in daily life.ppt

20ME702– MECHATRONICS -UNIT-3.ppt
20ME702– MECHATRONICS -UNIT-3.ppt20ME702– MECHATRONICS -UNIT-3.ppt
20ME702– MECHATRONICS -UNIT-3.pptMohanumar S
 
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS Mohanumar S
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the ArduinoWingston
 
Embedded systems optimization memory requirments.pptx
Embedded systems optimization memory requirments.pptxEmbedded systems optimization memory requirments.pptx
Embedded systems optimization memory requirments.pptxsatheeshKumar750
 
Unit iii microcontrollers final1
Unit iii microcontrollers final1Unit iii microcontrollers final1
Unit iii microcontrollers final1Saritha Reddy
 
PROGRAMMABLE PERIPHERAL INTERFCAE.ppt
PROGRAMMABLE PERIPHERAL INTERFCAE.pptPROGRAMMABLE PERIPHERAL INTERFCAE.ppt
PROGRAMMABLE PERIPHERAL INTERFCAE.pptkarthik R
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
Mod-2 M&M.pptx
Mod-2 M&M.pptxMod-2 M&M.pptx
Mod-2 M&M.pptxTechCook1
 
Io (2)
Io (2)Io (2)
Io (2)Aisu
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino unoRahat Sood
 
analog to digital converter and dac final
analog to digital converter and dac finalanalog to digital converter and dac final
analog to digital converter and dac finalDrVikasMahor
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfVikasMahor3
 
Interfacing ics for microprocessor
Interfacing ics for microprocessorInterfacing ics for microprocessor
Interfacing ics for microprocessorTHANDAIAH PRABU
 

Ähnlich wie knowledge in daily life.ppt (20)

8155 GPPI
8155 GPPI8155 GPPI
8155 GPPI
 
8255 & IO Interfacing.pdf
8255 & IO Interfacing.pdf8255 & IO Interfacing.pdf
8255 & IO Interfacing.pdf
 
20ME702– MECHATRONICS -UNIT-3.ppt
20ME702– MECHATRONICS -UNIT-3.ppt20ME702– MECHATRONICS -UNIT-3.ppt
20ME702– MECHATRONICS -UNIT-3.ppt
 
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS
Unit 3-PROGRAMMABLE PERIPHERAL INTERFACE-ME6702– MECHATRONICS
 
8255.pdf
8255.pdf8255.pdf
8255.pdf
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Embedded systems optimization memory requirments.pptx
Embedded systems optimization memory requirments.pptxEmbedded systems optimization memory requirments.pptx
Embedded systems optimization memory requirments.pptx
 
Unit iii microcontrollers final1
Unit iii microcontrollers final1Unit iii microcontrollers final1
Unit iii microcontrollers final1
 
PROGRAMMABLE PERIPHERAL INTERFCAE.ppt
PROGRAMMABLE PERIPHERAL INTERFCAE.pptPROGRAMMABLE PERIPHERAL INTERFCAE.ppt
PROGRAMMABLE PERIPHERAL INTERFCAE.ppt
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Mod-2 M&M.pptx
Mod-2 M&M.pptxMod-2 M&M.pptx
Mod-2 M&M.pptx
 
Programmable Peripheral Devices
Programmable Peripheral Devices Programmable Peripheral Devices
Programmable Peripheral Devices
 
Io (2)
Io (2)Io (2)
Io (2)
 
Port Interfacing
Port InterfacingPort Interfacing
Port Interfacing
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 
analog to digital converter and dac final
analog to digital converter and dac finalanalog to digital converter and dac final
analog to digital converter and dac final
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdf
 
Em s7 plc
Em s7 plcEm s7 plc
Em s7 plc
 
Interfacing ics for microprocessor
Interfacing ics for microprocessorInterfacing ics for microprocessor
Interfacing ics for microprocessor
 

Mehr von SunilSharma941036

Sustainability definition meaning methods and trends
Sustainability definition meaning methods and trendsSustainability definition meaning methods and trends
Sustainability definition meaning methods and trendsSunilSharma941036
 
4d printing for the future to advance manufacturing.pptx
4d printing for the future to advance manufacturing.pptx4d printing for the future to advance manufacturing.pptx
4d printing for the future to advance manufacturing.pptxSunilSharma941036
 
Biomimicry AN introduction for design.pptx
Biomimicry AN introduction for design.pptxBiomimicry AN introduction for design.pptx
Biomimicry AN introduction for design.pptxSunilSharma941036
 
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.pptSunilSharma941036
 
Presentation for Biofouling to solve.pptx
Presentation for Biofouling to solve.pptxPresentation for Biofouling to solve.pptx
Presentation for Biofouling to solve.pptxSunilSharma941036
 
Types of biological information.pptx
Types of biological information.pptxTypes of biological information.pptx
Types of biological information.pptxSunilSharma941036
 
Guidelines for preparation.pptx
Guidelines for preparation.pptxGuidelines for preparation.pptx
Guidelines for preparation.pptxSunilSharma941036
 
FINAL SOC and DSOC instructions.pptx
FINAL SOC and DSOC instructions.pptxFINAL SOC and DSOC instructions.pptx
FINAL SOC and DSOC instructions.pptxSunilSharma941036
 

Mehr von SunilSharma941036 (15)

Sustainability definition meaning methods and trends
Sustainability definition meaning methods and trendsSustainability definition meaning methods and trends
Sustainability definition meaning methods and trends
 
4d printing for the future to advance manufacturing.pptx
4d printing for the future to advance manufacturing.pptx4d printing for the future to advance manufacturing.pptx
4d printing for the future to advance manufacturing.pptx
 
Biomimicry AN introduction for design.pptx
Biomimicry AN introduction for design.pptxBiomimicry AN introduction for design.pptx
Biomimicry AN introduction for design.pptx
 
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt
1.-MSIE-12-T-M1S1-Le01 Augmented Reality in an Industry 4.0 Environment.ppt
 
Presentation for Biofouling to solve.pptx
Presentation for Biofouling to solve.pptxPresentation for Biofouling to solve.pptx
Presentation for Biofouling to solve.pptx
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Types of biological information.pptx
Types of biological information.pptxTypes of biological information.pptx
Types of biological information.pptx
 
Guidelines for preparation.pptx
Guidelines for preparation.pptxGuidelines for preparation.pptx
Guidelines for preparation.pptx
 
KNRE.ppt
KNRE.pptKNRE.ppt
KNRE.ppt
 
Demographics.pptx
Demographics.pptxDemographics.pptx
Demographics.pptx
 
Policy.pptx
Policy.pptxPolicy.pptx
Policy.pptx
 
FINAL SOC and DSOC instructions.pptx
FINAL SOC and DSOC instructions.pptxFINAL SOC and DSOC instructions.pptx
FINAL SOC and DSOC instructions.pptx
 
CVD and PVD.ppt
CVD and PVD.pptCVD and PVD.ppt
CVD and PVD.ppt
 
LIGA Presentation.pdf
LIGA Presentation.pdfLIGA Presentation.pdf
LIGA Presentation.pdf
 
Graphical Abstarct.pptx
Graphical Abstarct.pptxGraphical Abstarct.pptx
Graphical Abstarct.pptx
 

Kürzlich hochgeladen

GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry Areesha Ahmad
 
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....muralinath2
 
Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfSumit Kumar yadav
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learninglevieagacer
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceAlex Henderson
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusNazaninKarimi6
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxSilpa
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptxSilpa
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspectsmuralinath2
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.Silpa
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxRenuJangid3
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIADr. TATHAGAT KHOBRAGADE
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY1301aanya
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Silpa
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learninglevieagacer
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxSilpa
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Silpa
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxSuji236384
 

Kürzlich hochgeladen (20)

GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
 
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
 
Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdf
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical Science
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptx
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptx
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptx
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
 

knowledge in daily life.ppt

  • 2. ACOE255 2 Introduction • In a typical computer system, the user communicates with the computer via standard peripheral devices such as the keyboard, mouse, display, printer e.t.c. • Furthermore computers and microprocessor based systems are used in instrumentation or automatic control applications. In such cases it is necessary that the microprocessor reads the state of input devices (switches, sensors) and activate some output devices (motors, heaters, lights). • The I/O interface is required to enable the interface between the microprocessor and the peripheral devices. • The peripheral devices are connected on a microprocessor system through the Input/Output ports. • The I/O interface provides the following: – Isolation between the buses and the peripheral devices. – Address decoding. – Synchronization/Latching.
  • 3. ACOE255 3 Isolated vs Memory-mapped I/O • Isolated I/O – I/O locations are separate from memory locations – Special I/O instructions are used – The most common technique for Intel microprocessors – Advantage: More space for memory – Disadvantage: Additional control signals (IO/M) and instructions increase complexity • Memory-mapped I/O – I/O devices are treated as memory locations in the memory map – Any memory transfer instruction can be used (MOV, LDR, STR etc) – Advantages: Simpler decoding circuitry, no special instructions required – Disadvantage: A portion of the memory system is used as the I/O map, reducing the memory available to applications
  • 4. ACOE255 4 Input/Output Instructions • The 8088 and 80X86 processors use the 16 lower address lines (A0 to A15) to address I/O devices. This limits the maximum number of I/O ports to 64K. • The IN instruction copies the content of an input port to register AL, AX or EAX. • The OUT instruction copies the content of register AL, AX, or EAX to an output port. • Register AL is used for 8-bit ports, AX for 16-bit ports and EAX for 32-bit ports. • The 8088 and 80X86 processors support two I/O addressing modes. – Fixed Address. The address is directly specified in the instruction as an 8-bit number. That is loaded on the address lines A0 to A7. Address lines A8 to A15 are set to 00. • IN AL,30H ;Read input port 0030H into register AL • OUT 30H,AL ;Copy register AL to output port 0030H. – Variable Address. The address is specified through register DX as a 16-bit address. • MOV DX,3A0H ;Set I/O address • IN AL,DX ;Read input port [DX] or 3A0H into register AL. • OUT DX,AL ;Copy register AL to output port [DX] or 3A0H
  • 5. ACOE255 5 High Level Language Input/Output Instructions (Pascal) • Input/Output using Pascal: I/O is obtained using the ‘Port[ ]’ instruction. – X := Port[PortAddress]; /* Copy the contents of the specified port into X */ – Port[PortAddress] := X; /* Copy the contents of X into the specified port */ • Input/Output using Delphi: Delphi does not allow direct access to I/O ports. This can be done by inserting assembly language code into Delphi as follows: asm ; code equivalent to ‘value:=port[portaddress]; begin mov dx,portaddress ;specify the port address in al,dx ;input from the port specified by “dx” into “al” mov value,al ;copy input data into variable ‘value’ end; asm ; code equivalent to ‘port[portaddress] := value; begin mov dx,portaddress ;specify the port address mov al,value ;move output data into register “al” out dx,al ;output data to the port specified by “dx” end;
  • 6. ACOE255 6 High Level Language Input/Output Instructions (C/C++) • C/C++ does not allow direct access to I/O ports. This can be done by inserting assembly language code into the C/C++ code as follows: __asm ; code equivalent to ‘value:=port[portaddress]; { mov dx,portaddress ;specify the port address in al,dx ;input from the port specified by “dx” into “al” mov value,al ;copy input data into variable ‘value’ } __asm ; code equivalent to ‘port[portaddress] := value; { mov dx,portaddress ;specify the port address mov al,value ;move output data into register “al” out dx,al ;output data to the port specified by “dx” }
  • 7. ACOE255 7 Input/Output Using DLLs (C/C++) • For protection purposes, modern operating systems such as the Windows XP do not allow the use of the IN and the OUT instructions in the users programs. • A way to have access to I/O ports is through libraries (DLL files) developed for this purpose. Such a library is the inout32.dll • To use this library in Visual Studio (C++) we must: – Add the inout32.lib file in the Linker properties • Project ->Properties->Linker->Input->Additional Dependencies – Define the two functions for input and output and use them accordingly short _stdcall Inp32(short PortAddress); void _stdcall Out32(short PortAddress, short data); main() { short Inval = Inp32(889); /* input from port 889 into variable “Inval”*/ Out32(888,0x2f); /* Output the hex value 2f to port 888 */ }
  • 8. ACOE255 8 Simple Input Port • An input port can be implemented using a simple octal buffer such as the 74LS244. • The address decoding circuit enables the three-state buffers of the 74LS244 whenever the port address is selected by the processor. In such a case the state of the input devices appears on the data bus. • The address decoding circuit is enabled only if the IO/M signal is set High by the 8088 (Low for the x86 processors) and the RD signal is Low. A19 D7 D0 RD WR IO/M' 8088 System A0 +5V LS244 G1 G2 A11 A10 A9 A8 A7 A6 A5 A4 A11A10 A9 A8 A4 A7 A6 A5 A1 A3 A2 A0 0 1 0 0 0 0 1 1 X X X X Address 460H to 46FH Switch Open => Logic 1 Switch Closed => Logic 0
  • 9. ACOE255 9 Simple Output Port (Using the 74LS373) • An output port can be implemented using a simple octal latch such as the 74LS373. • The address decoding circuit enables the D-latches of the 74LS373 whenever the port address is selected by the processor. In such a case the state of the data bus is latched to the output devices. • The address decoding circuit is enabled only if the IO/M signal is set High by the 8088 (Low for the x86 processors) and the WR signal is Low. LS373 D Q EN EN OE A19 D7 D0 RD WR IO/M' 8088 System A0 +5V A11 A10 A9 A8 A7 A6 A5 A4 A11A10 A9 A8 A4 A7 A6 A5 A1 A3 A2 A0 0 1 0 0 0 0 1 1 X X X X Address 460H to 46FH Logic 1 => LED is OFF Logic 0 => LED is ON
  • 10. ACOE255 10 Simple Output Port (Using the 74HCT573) • The 74HCT573 is pin compatible with the 74LS373. There are three significant differences: – The ‘573 has all inputs on the left side and all outputs on the right side of the IC, while the ‘373 has the even numbered inputs on the left side and the odd numbered inputs on the right side. Thus the ‘573 is easier to by handled on PCB boards. – The HCT573 has a 20mA current sink and a 20mA current source, thus it can drive a LED connected either to the ground or to +5V. The LS373 has a 16mA current sink and a 400uA current source, thus it can only drive a LED connected to +5V. – The HCT family is faster than the LS family. HCT573 D Q EN EN OE A19 D7 D0 RD WR IO/M' 8088 System A0 A11 A10 A9 A8 A7 A6 A5 A4 A11 A10 A9 A8 A4 A7 A6 A5 A1 A3 A2 A0 1 0 0 0 1 0 1 0 X X X X Address 850H to 85FH +5V Logic 1 => LED is OFF Logic 0 => LED is ON Logic 1 => LED is ON Logic 0 => LED is OFF
  • 11. ACOE255 11 Simple I/O Example 1 (Hardware) • Draw a circuit to show how 8 switches can be connected on the input port 3AH and 8 LEDs on the output port 5CH.
  • 12. ACOE255 12 Simple I/O Example 1 (Software) Write a program to keep reading the state of the switches and switch ON the LED at the position form by the switches at D2, D1 and D0 (i.e. 3X8 decoder). Pseudo Code: Repeat Read Input port in InVal Mask out D2,D1,D0 from InVal if InVal = 0 then OutVal = 1 if if InVal = 1 then OutVal = 2 if InVal = 2 then OutVal = 4 if InVal = 3 then OutVal = 8 if InVal = 4 then OutVal = 16 if if InVal = 5 then OutVal = 32 if InVal = 6 then OutVal = 64 if InVal = 7 then OutVal = 128 Write OutVal to Output port Until keypressed C/C++ Code main() { short InVal, OutVal = 0; do { InVal = Inp32(0x3a); InVal = InVal & 0x7; if (InVal == 0) OutVal = 0x1; if (InVal == 1) OutVal = 0x2; if (InVal == 2) OutVal = 0x4; if (InVal == 3) OutVal = 0x8; if (InVal == 4) OutVal = 0x10; if (InVal == 5) OutVal = 0x20; if (InVal == 6) OutVal = 0x40; if (InVal == 7) OutVal = 0x80; Out32(0x5c,OutVal); } while (!_kbhit()); }
  • 13. ACOE255 13 Mask Operations (a) Write a program to keep reading the . (b) Write a program to keep reading the state of the switches and switch ON the LEDs for which the corresponding switch is closed.
  • 14. ACOE255 14 Simple I/O Example 2 Four float switches and four LEDs are used to indicate the level of a liquid in the tank shown below. The switches and the LEDs are connected on a computer through an interface board with an input and an output port occupying the address 460H to 46FH. • Draw the circuit diagram of the interface board. • Write a program to keep reading the state of the float switches and display the liquid level on the LEDs. If an error is detected then switch ON all LEDs. Interface Board Empty Low Half Full DI3 DI2 DI1 DI0 DO3 DO2 DO1 DO4 Closed Closed Open Open High DO0 DI3 DI2 DO3 DO2 DO1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 DI1 DI0 Empty Low Error Half Error Error Error High Error Error Error Error Error Error Error Full 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 DO0 DO4 State
  • 15. ACOE255 15 Simple I/O Example 2 (Circuit Diagram) A19 D7 D0 RD WR IO/M' 8088 System A0 +5V HCT573 D Q EN EN OE LS244 G1 G2 DI0 DI1 DI2 DI3 DO4 DO3 DO2 DO1 DO0 A11 A10 A9 A8 A7 A6 A5 A4 A11A10 A9 A8 A4 A7 A6 A5 A1 A3 A2 A0 0 1 0 0 0 0 1 1 X X X X Address 460H to 46FH
  • 16. ACOE255 16 Simple I/O Example 2 (Software using Case/Switch Statement) Pseudo Code: Set OutVal to 0, i.e switch off all leds Repeat Read Input port in InVal Mask out D3,D2,D1,D0 from InVal Case of InVal 0: OutMask = 1 1: OutMask = 2 3: OutMask = 4 7: OutMask = 8 FH: OutMask = 10H else OutMask = 1FH Mask in D4 to D0 of OutMask in OutVal Write OutVal to Output port Until keypressed C/C++ Code main() { short InVal, OutVal = 0; do { InVal = Inp32(0x460); InVal = InVal & 0xf; switch (InVal) { case 0: OutMask = 1; break; case 1: OutMask = 2; break; case 3: OutMask = 4; break; case 7: OutMask = 8; break; case 0xf: OutMask = 0x10; break; default OutMask = 0x1f; } OutVal = (OutVal & 0xe0) | OutMask; Out32(0x460,OutVal); } while (!_kbhit()); }
  • 17. ACOE255 17 Simple I/O Example 2 (Software using array as a lookup table) Pseudo Code: Table[0] = 00001 /* Table[1] = 00010 /* Table[3] = 00100 /* Table[7] = 01000 /* Table[15] = 10000 /* Table[rest] = 111111 /* Repeat Read Input port in InVal Mask out D2,D1,D0 from InVal Mask in D2,D1,D0 of Table[InVal] to OutVal Write OutVal to Output port Until keypressed C/C++ Code main() { short InVal, OutVal = 0; short Table[16] = 0x1, 0x2, 0x1f, 0x4, 0x1f, 0x1f, 0x1f, 0x8, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x10; do { InVal = Inp32(0x460); InVal = InVal & 0xf; OutMask = Table[InVal]; OutVal = (OutVal & 0xe0) | OutMask; Out32(0x460,OutVal); } while (!_kbhit()); }
  • 18. ACOE255 18 DC Motor Speed and Direction Control • The speed of a DC motor is proportional to the DC voltage applied at its terminal. – Thus the speed can be controlled by controlling the DC voltage. • The DC voltage can be controlled by: – Inserting a resistor in series with the DC motor. • Unnecessary dissipation of energy on the resistor. – Using Pulse Width Modulation (PWM) • The direction of rotation a DC motor is reversed by reversing the polarity of the DC voltage applied at its terminal. – This can be obtained using a relay (change-over connection). – Connecting a relay on an output port requires the use of high current drivers such as the ULN2803 and diodes to protect the output transistors due to Lenz’s law. • Special drivers (H-drivers) can also be used to provide both speed control and direction control. Average Voltage
  • 19. ACOE255 19 DC motor interface example A DC motor is connected to a computer as shown below. The switches and the motor are connected on an input and an output port occupying the address 460H to 46FH. • Draw a circuit of the interface and the connections to the motor • Write a program to keep reading the state of the switches and control the operation of the motor accordingly. 0 1 0 1 0 1 Start/Stop Fast/Slow Fwrd/Rev. Interface Board DC Motor
  • 20. ACOE255 20 DC motor interface example(Circuit Diagram) A11A10 A9 A8 A4 A7 A6 A5 A1 A3 A2 A0 0 1 0 0 0 0 1 1 X X X X Address 460H to 46FH RL 1 ULN2803 Com RL 2 RL 2 M A19 D7 D0 RD WR IO/M' 8088 System A0 +5V HCT573 D Q EN EN OE LS244 G1 G2 DI7 DI6 DI5 DI4 DO2 DO1 DO0 A11 A10 A9 A8 A7 A6 A5 A4 On/Off Fast/Slow Frwd/Rev. +5V +5V +5V DI3 DI2 DI1 DI0
  • 21. ACOE255 21 DC motor interface example (Software using conditional execution) Pseudo Code: Set OutVal to 0, i.e motor is OFF Repeat Read Input port in InVal If On/Off bit = 1 then OutVal(D0) = 1 else OutVal(D0) = 0 If Fast/Slow bit = 1 then OutVal(D1) = 1 else OutVal(D1) = 0 If Frwd/Rev bit = 1 then OutVal(D2) = 1 else OutVal(D2) = 0 Write OutVal to Output port Until keypressed
  • 22. ACOE255 22 DC motor interface example (Software using a lookup table) Pseudo Code: Table[0] = 000 /* 000 ->motor is Off Table[1] = 000 /* 001 ->motor is Off Table[2] = 010 /* 010 -> On-Slow-Rev Table[3] = 011 /* 011 -> On-Slow-Frwd Table[4] = 000 /* 100 -> motor is Off Table[5] = 000 /* 101 -> motor is Off Table[6] = 110 /* 110 ->On-Fast-Rev Table[7] = 111 /* 111 ->On-Fast-Frwd Repeat Read Input port in InVal Mask out D2,D1,D0 from InVal Mask in D2,D1,D0 of Table[InVal] to OutVal Write OutVal to Output port Until keypressed
  • 23. ACOE255 23 7-Segment Displays • Used to display the digits from 0 to 9, as well as many letters (A,b,C,d,E,F,L,H) • Consists of seven leds connected to a common point • Can be common-anode or common-cathode a b c d e f g a b c d e f g a b c d e f g a b c d e f g +Vcc 0: OFF 1: ON 0: ON 1: OFF Common Cathode Common Anode Can be connected directly on an O/P port Through a BCD/7 segment decoder OR HCT573 D Q EN EN OE DO4 DO3 DO2 DO1 DO0 DO5 DO6 DO7 a b c d e f g a b c d e f g HCT573 D Q EN EN OE DO4 DO3 DO2 DO1 DO0 DO5 DO6 DO7 a b c d e f g a b c d e f g CD4511 D OE A /LE C B D /BL /LT EN Q Latch BCD-7seg decoder Buffer
  • 24. ACOE255 24 7-segment Displays – Example1 A19 D7 D0 RD WR IO/M' 8088 System A0 +5V HCT573 D Q EN EN OE LS244 G1 G2 DI0 DI1 DI2 DI3 DO4 DO3 DO2 DO1 DO0 A11 A10 A9 A8 A7 A6 A5 A4 DO5 DO6 DO7 a b c d e f g a b c d e f g x 0 1 1 1 1 1 1 3F x 0 0 0 1 1 0 0 0C x 1 1 1 0 1 1 0 76 x 1 0 1 1 1 1 0 5E x 1 0 0 1 1 0 1 4D x 1 0 1 1 0 1 1 5B x 1 1 1 1 0 1 1 7B x 0 0 0 1 1 1 0 0E x 1 1 1 1 1 1 1 7F x 1 0 0 1 1 1 1 4F x 1 1 0 1 1 1 1 6F x 1 1 1 1 0 0 1 79 x 0 1 1 0 0 1 1 33 x 1 1 1 1 1 0 0 7C x 1 1 1 0 0 1 1 73 x 1 1 0 0 0 1 1 63 - g f e d c b a D0 D1 D2 D3 D4 D5 D6 D7 • Draw a circuit to show how a common cathode 7-segment display can be connected on an o/p port and four switches on an i/p port both occupying the address range 860h to 86Fh. • Write a program to read the state of the switches and display the binary number formed by the switches as a hexadecimal digit.
  • 25. ACOE255 25 7-segment Displays – Example1: Program
  • 26. ACOE255 26 7-Segment Displays: Example 2 Four float switches and a 7-segment display are used to indicate the level of a liquid in the tank shown below. The switches and the display are connected on a computer through an interface board with an input and an output port occupying the address 460H to 46FH. Draw the circuit diagram of the interface board. Write a program to keep reading the state of the float switches and display the liquid level on the display using the digits F(Full), H(High), A (Half), L(Low) and E(Empty). If an error is detected then switch ON the decimal point. Interface Board DI3 DI2 DI1 DI0 DO3 DO2 DO1 DO4 DO0 DO6 DO5 DO7 a b c d e f g a b c d e f g dp Open Open Closed Closed DI3 DI2 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 DI1 DI0 Empty Low Error Half Error Error Error High Error Error Error Error Error Error Error Full State E L . A . . . H . . . . . . . F Digit Code
  • 27. ACOE255 27 7-segment Displays – Example1: Program
  • 28. ACOE255 28 7-segment Displays – Example3 A19 D7 D0 RD WR IO/M' 8088 System A0 +5V HCT573 D Q EN EN OE LS244 G1 G2 DI0 DI1 DI2 DI3 DO4 DO3 DO2 DO1 DO0 A11 A10 A9 A8 A7 A6 A5 A4 DO5 DO6 DO7 a b c d e f g a b c d e f g x 0 1 1 1 1 1 1 3F x 0 0 0 1 1 0 0 0C x 1 1 1 0 1 1 0 76 x 1 0 1 1 1 1 0 5E x 1 0 0 1 1 0 1 4D x 1 0 1 1 0 1 1 5B x 1 1 1 1 0 1 1 7B x 0 0 0 1 1 1 0 0E x 1 1 1 1 1 1 1 7F x 1 0 0 1 1 1 1 4F x 1 1 0 1 1 1 1 6F x 1 1 1 1 0 0 1 79 x 0 1 1 0 0 1 1 33 x 1 1 1 1 1 0 0 7C x 1 1 1 0 0 1 1 73 x 1 1 0 0 0 1 1 63 - g f e d c b a D0 D1 D2 D3 D4 D5 D6 D7 • Draw a circuit to show how a common cathode 7-segment display can be connected on an o/p port and four switches on an i/p port both occupying the address range 860h to 86Fh. • Write a program to read the state of the switches and display the binary number formed by the switches as a hexadecimal digit.
  • 29. ACOE255 29 7-segment Displays– Example1: Program
  • 30. ACOE255 30 7-segment Displays– Example1 A19 D7 D0 RD WR IO/M' 8088 System A0 +5V HCT573 D Q EN EN OE LS244 G1 G2 DI0 DI1 DI2 DI3 DO4 DO3 DO2 DO1 DO0 A11 A10 A9 A8 A7 A6 A5 A4 DO5 DO6 DO7 a b c d e f g a b c d e f g x 0 1 1 1 1 1 1 3F x 0 0 0 1 1 0 0 0C x 1 1 1 0 1 1 0 76 x 1 0 1 1 1 1 0 5E x 1 0 0 1 1 0 1 4D x 1 0 1 1 0 1 1 5B x 1 1 1 1 0 1 1 7B x 0 0 0 1 1 1 0 0E x 1 1 1 1 1 1 1 7F x 1 0 0 1 1 1 1 4F x 1 1 0 1 1 1 1 6F x 1 1 1 1 0 0 1 79 x 0 1 1 0 0 1 1 33 x 1 1 1 1 1 0 0 7C x 1 1 1 0 0 1 1 73 x 1 1 0 0 0 1 1 63 - g f e d c b a D0 D1 D2 D3 D4 D5 D6 D7 • Draw a circuit to show how common cathode 7-segment display can be connected on an o/p port and four switches on an i/p port both occupying the address range 860h to 86Fh. • Write a program to read the state of the switches and display the binary number formed by the switches as a hexadecimal digit.
  • 31. ACOE255 31 Homework- Question 1 a) Draw a circuit diagram to show how four switches and two 7-segment displays can be interfaced to an 8088 based system occupying the address 10H to 1FH, 20H to 2FH and 30H to 3FH respectively. b) Write a program to read the binary number formed by the four switches and display the equivalent decimal number on the 7-segment displays. For example if the switches form the number 0110, the displays should display the number 06, and if the switches form the number 1110, then the displays should display the number 14.
  • 32. ACOE255 32 a) Draw a circuit diagram to show how four switches and a 7-segment display can be interfaced to an 8088 based system occupying the address A0H to AFH, F0H to FFH respectively. b) Write a program to read the state of the switches and display on the 7-segment display the letter: • H, if there are more switches closed than open, • L, if there are less switches closed than open, • E, if the number of switches closed is equal to the number of switches open. Homework- Question 2
  • 33. ACOE255 33 a) Draw a circuit diagram to show how six switches and eight Leds can be interfaced to an 8088 based system occupying the address 30H to 3FH, 20H to 2FH respectively. b) Write a program to read the binary number formed by the six switches and display the equivalent Binary Coded Decimal number on the Leds. For example if the switches form the number 100101, the displays should display the number 00110111, since (100101)2 = (00110111)BCD. Homework- Question 3
  • 34. ACOE255 34 a) Draw a circuit diagram to show how the following can be interfaced to an 8088 based system: i. Four switches connected on an I/P port occupying the address range from 30H to 3FH. ii. Eight Leds connected on an O/P port occupying the address range from 20H to 2FH. b) Write a program to read the BCD number formed by the four switches, and display it on the eight Leds the square of the input number in BCD form. If the number formed by the switches is an invalid BCD number, then all of the Leds should be switched ON. – For example if the switches form the number 00000101 then the Leds should display 00100101, since (00000101)BCD = (05)10 and 52 = 25 = (00100101)BCD – If the number formed by the switches is 00001100 then the Leds should display 11111111 since 1100 is an invalid BCD number. Homework- Question 4
  • 35. ACOE255 35 a) Draw a circuit diagram to show how a common cathode 7-segment display can be connected on an output port, occupying the address CAH. b) Write a program to display the digits from 0 to 9 on the 7-segment display with a 1-second delay between digits. c) Write a procedure to display on the 7-segment display, the letter E if the contents of the variable INVAL is equal to 80H, the letter H if INVAL is greater than 80H, or the letter L if INVAL is less than 80H. d) Write a program that keeps reading the binary number from the input port 0AAH and displays on the 7-segment display, a letter according to the table given below. Homework- Question 5 xxxxx000 xxxxx001 xxxxx010 xxxxx011 xxxxx100 xxxxx101 xxxxx110 xxxxx111 E I L U H Γ Ξ F
  • 36. ACOE255 36 a) Draw a circuit diagram to show how the following can be interfaced to an 8088 system i. Three switches connected on an I/P port occupying the address range from 60H to 6FH. ii. Eight Leds connected on an O/P port occupying the address range from 50H to 5FH. b) Write a program to i. read the code formed by the three switches in a 1-second time intervals, ii. convert the input code into a binary value according to the table below and store it in an array called BINV, and iii. display it as a bar graph on the eight Leds as shown in figure below For example if the switches form the number 101 then the number 110 must be stored in the array BINV and the Leds should display 11111110. 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 0 1 0 1 1 1 1 1 1 1 Input Binary Bar Graph Homework- Question 6
  • 37. ACOE255 37 THE 82C55 PROGRAMMABLE PERIPHERAL INTERFACE (PPI) VCC: The +5V power supply pin. GND: GROUND D0-D7: I/O DATA BUS RESET: A high on this input clears the control register and all ports (A, B, C) are set to the input mode with the “Bus Hold” circuitry turned on. CS: Chip select is an active low input used to enable the 82C55A onto the Data Bus for CPU communications. RD: Read is an active low input control signal used by the CPU to read status information or data via the data bus. WR: Write is an active low input control signal used by the CPU to load control words and data into the 82C55A. A0-A1: Address input signals, in conjunction with the RD and WR inputs, control the selection of one of the three ports or the control word register (00 – Port A, 01 – Port B, 10 – Port C, 11 – CR). PA0-PA7 (I/O PORT A): 8-bit input and output port. PB0-PB7 (I/O PORT B): 8-bit input and output port. PC0-PC7 (I/O PORT C): 8-bit input and output port. •A popular interfacing component, for interfacing TTL-compatible I/O devices to the microprocessor. •Requires insertion of wait states if used with a microprocessor using higher that an 8 MHz clock. •PPI has 24 pins for I/O that are programmable in groups of 12 pins and three modes of operation (Basic I/O, Strobed I/O, Strobed Bi-directional Bus I/O). •In the PC, an 82C55 or its equivalent is decoded at I/O ports 60H-63H, interfacing keyboard and Parallel printer port).
  • 38. ACOE255 38 INTERFACING 82C55 TO AN 8088 SYSTEM (ports 60H-63H) A19 D7 D0 RD WR IO/M' 8088 System A0 DI0 DI1 DI2 DI3 A7 A6 A5 A4 A3 A2 82C55 D7 D0 RD WR A0 A1 PA7 PA0 PB7 PB0 PC7 PC0 CS A0 A1
  • 39. ACOE255 39 EXAMPLE • Use a 82C55 PPI to interface four switches at address 60H and a SSD at address 62H A19 D7 D0 RD WR IO/M' 8088 System A0 +5V DI0 DI1 DI2 DI3 A7 A6 A5 A4 A3 A2 a b c d e f g a b c d e f g 82C55 D7 D0 RD WR A0 A1 PA7 PA0 PB7 PB0 PC7 PC0 CS A0 A1 DI0 DI1 DI2 DI3 DI0 DI1 DI2 DI3
  • 40. ACOE255 40 PROGRAMMING THE 82C55 • Mode 0 operation causes the PPI to function as either buffered input or latched output • The 82C55 is programmed through two internal command registers, selected through bit 7. • Command byte A – 0 Port C, PC3-PC0 (1-input, 0-output) – 1 Port B (1-input, 0-output) – 2 Mode (00-mode 0, 01-mode1) – 3 Port C, PC7-PC4 (1-input, 0-output) – 4 Port A (1-input, 0-output) – 5-6 Mode (00-mode 0, 01-mode 2, 1X-mode 2) – 7 Command byte select (always 1 for Command byte A) • Command byte B – Used in mode 1 and mode 2
  • 41. ACOE255 41 Example • Rewrite the program of the example of slide 30, this time using the PPI and setting up the ports as shown in the previous slide
  • 42. ACOE255 42 Homework • All examples of slides 31-36 can be modified to include PPI interfacing