Interfacing Lec 14 TMP
Interfacing Lec 14 TMP
INTERFACING
1
PART II
INTERFACING
2
IN THIS PART:
Chapter 5
Introduction
The 8255 PPI
The 8259 PIC
The 8251 USART
Memory Interfacing
3
OUTLINE
Introduction
The 8255 PPI
Memory Interfacing
4
INTRODUCTION
Two methods of communicating external equipment:
MEMORY MAPPED I/O
ISOLATED (DIRECT) I/O
location
A decoder translates memory addresses to chip select signals
5
INTRODUCTION
Peripheral Interfacing Needed
To design and implement an 8086 based microcomputer system
For the microprocessor to interact with the external world
7
INTRODUCTION
Direct I/O
Separate address spaces are set out for I/O ports
Uses 16-bit addressing (0000 – FFFF)
Advantage: none of the memory space is used for ports
Disadvantage: only specialized IN and OUT instructions can
be used to input or output data
E.g: IN AL, DX ;DX: port address
OUT DX, AL
8
PROGRAMMABLE PERIPHERAL
INTERFACE (PPI 8255A)
A general purpose programmable I/O device
Used for parallel data transfer (simple/inter. I/O)
Designed for use with Intel’s 8-bit , 16-bit and higher capability MPs as well
as most other MPs
It has 24 Input/Output lines (pins) which can be grouped into three 8-bit
parallel ports:
Port A (PA0-PA7)
Port B (PB0-PB7)
Port C (PC0-PC7)
All of the ports can function independently either as input or output ports
Achieved by programming the bits of an internal register of 8255 called control word
register
10
PPI 8255A
Pin diagram:
It is a 40 pin IC which is
used to I/P or O/P digital
signal
Has 24 I/O lines in 3 groups:
ports A, B, C
Connects peripheral devices
like printers, keyboards,
controllers, DACs, ADCs
11
THE 8255 PPI
PIN DIAGRAM
It is a 40 pin IC which is used to
I/P or O/P digital signal
12
THE 8255 PPI
SIGNAL DESCRIPTION
PA7-PA0:
These are eight port A lines that acts as either latched output or
buffered input lines depending upon the control word loaded into
the control word register.
PC7-PC4 :
Upper nibble of port C lines. They may act as either output latches
or input buffers lines.
This port also can be used for generation of handshake lines in
mode 1 or mode 2.
PC3-PC0 :
These are the lower port C lines, other details are the same as PC7-
PC4 lines.
PB0-PB7 : 13
These are the eight port B lines which are used as latched output
lines or buffered input lines in the same way as port A.
THE 8255 PPI
SIGNAL DESCRIPTION
RD
This is the input line driven by the microprocessor and should be low to
indicate read operation to 8255
WR
This is an input line driven by the microprocessor. A low on this line
indicates write operation
CS
This is a chip select line. If this line goes low, it enables the 8255 to
respond to RD and WR signals, otherwise RD and WR signal are
neglected
D0-D7
These are the data bus lines those carry data or control word to/from the
microprocessor
RESET 14
A logic high on this line clears the control word register of 8255. All ports
are set as input ports by default after reset
THE 8255 PPI
SIGNAL DESCRIPTION
A1-A0
These are the address input lines and are driven by the
microprocessor.
These address lines are used for addressing any one of the
four registers, i.e. three ports and a control word register as
given in table below.
A1 A0
Port A 0 0
Port B 0 1
Port C 1 0
Control Register 1 1
15
PPI 8255A
The connection to MP is thru:
data bus D0 – D7
Handshaking and address lines (RD’, WR’, A1, A0, RESET)
PORT C
CONTROL REGISTER
17
PPI 8255A – BLOCK DIAGRAM
18
THE 8255 PPI
BLOCK DIAGRAM
19
THE 8255 PPI
BLOCK DIAGRAM…
Data Bus Buffer
Tri-state bi-directional buffer used to interface the 8255 to system
data bus
Execution of I/O instructions by the CPU, either RD data from or
WR to into this buffer
O/P data from CPU to ports or Control Register and I/P data to CPU
from ports or status register all passed through the buffer
Control Logic
Accepts control signals (RD, WR) and inputs from address bus
Issues commands to individual group of control blocks (Group A and B)
Issues appropriate enabling signals to access required data/control words or
status word
20
THE 8255 PPI
BLOCK DIAGRAM…
Group A and Group B Controls
Theseblocks receive control from the CPU and issues
commands to their respective ports
Group A - PA and PCU (PC7 –PC4)
Group B - PCL (PC3 – PC0)
22
PPI 8255A - MODES
BSR Mode:
Individual bits of port C can be set/reset by sending OUT instruction
to control register
Do of the control word
Determines whether the bits are to be set or reset
D3, D2 and D1 of the control word
Determines the particular bit to be set or reset
Used to set/reset individual bits of port C when it is used for
control/status operation
23
PPI 8255A - MODES
I/O modes:
Mode 0 (Basic I/O )
Mode 1 (Strobed I/O)
Mode 2 (Bidirectional Strobed I/O)
26
PPI 8255A - MODES
Mode 0: simple I/O
Ports A and B are used (& programmed) as two simple 8-bit I/O ports, port C
as two 4-bit ports
27
PPI 8255A - MODES
Mode 1: I/O with handshake
I/O data transfer is controlled by handshake signals (i.e. when transfer speeds
are not same, e.g. printer)
Data Bus
STB’
Computer Printer
ACK’
BUSY
28
PPI 8255A - MODES
Mode 1 features:
Ports A and B function as 8-bit I/O ports
Each uses 3 lines from port C as handshake
31
PPI 8255A
MODE 1…
Mode 1 operation
32
PPI 8255A
MODE 1…
Input control signal definitions:
STB (Strobe input):
Generated by a peripheral device when a peripheral device has some valid data, it
sends a low STB signal.
34
PPI 8255A
MODE 1…
Output control signal definitions:
36
PPI 8255A - MODES
Mode 2: bi-directional data transfer
Allows bi-directional data transfer over a single data bus
37
PPI 8255A
MODE 2
Allows bi-directional data transfer over a single data
bus
Available for port A only
PC3 – PC7 used for handshaking
38
PPI 8255A
MODE 2…
Mode 2 operation
39
PPI 8255A
CONTROL WORD FORMATS
Two control word formats are used:
Mode set control word format
To set modes of each port
Port C bit Set/Reset control word format
To set particular bit in port C
42
PPI 8255A
PORT C BIT SET/RESET CW FORMAT
43
PPI 8255A CONTROL WORD
Port C bit Set/Reset CW
44
Mode 2: bi-directional data transfer
Allows bi-directional data transfer over a single data bus
mode 1
45
PPI 8255A CONTROL WORD
Control word (CW) formats
Highon RESET causes all ports to be in I/P mode
Two CW formats are used:
Mode set CW – to set modes of each port
Port C bit Set/Reset CW – to set particular bit in port C
instruction
46
PPI 8255A CONTROL WORD
E.g. Assume 8255A is located at FFF8H, control register
address is FFFEH, CW is to be set to 10001110B:
MOV AL, 10001110B
MOV DX, FFFEH
OUT DX, AL
47
PPI 8255A CONTROL WORD
Mode set CW
48
PPI 8255A CONTROL WORD
Port C bit Set/Reset CW
49
PPI 8255A CONTROL WORD
CW example: suppose we want to set:
Port A as mode 0 output
Port B as mode 1 input
50
PROGRAMMING PPI 8255A
The CW programs functionality of ports
Ports and CW reg map to I/O memory with assigned base
address (e.g. FFF8H)
PPI addresses:
Port Address Function e.g.
BASE_ADDR Port A FFF8H
“ +1 Port B FFF9H
“ +2 Port C FFFAH
“ +3 Control Register FFFBH
51
PROGRAMMING PPI 8255A
Example: the following program outputs the value 90H
(10010000B) to the control register:
MOV DX, CNTRL_REG ;setup PPI
with
MOV AL, 90H ;port B as
O/P
OUT DX, AL
Exercises: for the ff bit patterns, identify mode of operation:
01101000
10011000
52