Lecture 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Al-Nahrain University

College of Engineering
Department of Electronic and Communications Engineering
Fourth Year

Digital System Design


Lecture 4
2
3
4
5
6
Mode 0
Mode 0 selects what is called simple I/O operation.
By simple I/O, mean that the lines of the port can be
configured as level-sensitive inputs or latched
outputs. To set all ports for this mode of operation,
load bit D7 of the control register with logic 1, bits
D6D5=00, and D2 = 0. Logic 1 at D7 represents an
active mode set flag. Now port A and port B can be
configured as 8-bit input or output ports, and port C
can be configured for operation as two independent
4-bit input or output ports.
For example, if( 80)h=(10000000)2 is written to the
control register. Mode 0 operation is selected for all
three ports because bits D6,D5, and D2 are logic 0. At
the same time, the zeros in D4, D3, D1, and D0 set up
all port lines to work as outputs.
7
8
Example:
What is the mode and I/O configuration for ports A, B, and C of an 82C55A after
its control register is loaded with (82)16?
Solution:
Expressing the control register contents in binary form, we get
D7D6D5D4D3D2D1D0:= (10000010)2
Since D7 is 1, the modes of operation of the ports are selected by the control
word. The three least significant bits of the control word configure port B and
the lower four bits of port C:

Do = 0 Lower four bits of port C are outputs.


D1= 1 port B is an input port.
D2= 0 Mode 0 operation for both port B and the lower four bits of port C.
The next four bits configure the upper part of port C and port A
D3=0 Upper four bits of port C are outputs
D4=0 Port A is an output port
D6D5=00 Mode 0 operation for both port A and the upper part of port C.

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

Solution: A procedure that reads the


keyboard encoder and returns the ASCII
key code in AL:

BIT5 EQU 20H


PORTC EQU 22H
PORTA EQU 20H
**IN AL, PORTC ;poll IBF bit
AND AL,BIT5
JZ **
IN AL,PORTA ;get ASCII data
INT 3

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

You might also like