Lecture 4
Lecture 4
Lecture 4
College of Engineering
Department of Electronic and Communications Engineering
Fourth Year
9
Mode 1
Mode 1 operation represents what is known as strobed I/O.
The ports of the 82C55A are put into this mode of operation
by setting D7= 1 to activate the mode-set flag and setting
D6D5= 01 and D2= 1.
In this way, the A and B ports are configured as two
independent byte-wide I/O ports, each of which has a 4-bit
control/data port associated with it. The control data ports are
formed from the lower and upper nibbles of port C,
respectively. The figure lists the mode1 functions of each pin
at ports A,B and C.
When configured in this way, data applied to an input port
must be strobed in with a signal produced in external
hardware. An output port in mode 1 is provided with
handshake signals that indicate when new data are available
at its outputs and when an external device has read these
values.
10
Mode 1 (input)
11
Example: Using 82C55 for strobed input operation of a keyboard
12
Mode 1 (output)
13
14
Mode 2
15
MODE2 Control Word MODE 2
16
17
18
Port C Bit Set/Reset
19
Example:
The interrupt-control flag INTEA for output port A in mode 1 is controlled by
PC6. Using the set/reset feature of the 82C55A, what command code must
be written to the control register of the 82C55A to set it to enable the
control flag?
Solution:
To use the set/reset feature, D7 must be logic 0. Moreover, INTEA is to be
set; therefore, D0 must be logic 1. Finally, to select PC6, the code at bits
D3D2D1 must be 110. The rest of the bits are don't-care states. This gives us
the control word:
D7D6D5D4D3D2D1D0= (0XXX1101)2
Replacing the don't-care states with the 0 logic level, we get:
D7D6D5D4D3D2D1D0= (00001101)2=0D16
20
Example:
What control word must be written into the control register of the 82C55A such that
port A is configured for bidirectional operation and port B is setup with mode 1
outputs?
Solution:
To configure the operating mode of the ports of the 82C55A, D7 must be 1: D7=1
Port A is set up for bidirectional operation by making D6 logic 1. In this case, D5 through
D3 are don't-care states:
D6=1
D5D4D3 = XXX
Mode 1 is selected for port B by logic 1 in bit D2 and output operation by logic 0 in D1.
Since mode operation has been selected, D0 is a don't-care state:
D2=1
D1= 0
Do: X
This gives the control word:
D7D6D5D4D3D2D1D0= (11XXX10X)2
Assuming logic 0 for the don't-care states, we get:
D7D6D5D4D3D2D1D0=: (11000100)2 =C416
21
Example:
Write the sequence of instructions needed to load the control register of an 82C55A with
the control word formed in example above. Assume that the control register of the
82C55A resides at address 0F16 of the I/O address space.
Solution:
First we must load AL with C4. This is the value of the control word that is to be written to
the control register at address 0F16. The move instruction used to load AL is
MOV AL, C4H
These data are output to the control register with the OUT instruction
OUT OFH, AL
Because the I/O address of the control register is less than FF16, this instruction uses direct
I/O.
22