Académique Documents
Professionnel Documents
Culture Documents
1
8255
• All ports are 8 bits
• PA0 - PA7:
– 8 bits IN (modes 0 or 1)
Computer Interfacing
– 8 bits IN (modes 0)
– 8 bits OUT (modes 0)
– Each bit separately (mode BSR)
– Few pins (4,5) (?)
3
CS A1 A0 Selects
Computer Interfacing
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 I Control register
1 X X !
is not selected 8255
4
Control Word Format
(I/O Mode)
Computer Interfacing
5
Mode selection of the 8255A
6
Mode 0
7
Mode 1
8
Mode 2
9
BSR (bit set/reset) mode
10
BSR (bit set/reset) mode
11
Example
12
Solution:
control word.
• The x's are for "don't care" and generally are set to zero.
• The CPU services various devices. There are two ways for the CPU
to provide service to those devices: interrupts and polling.
• In the interrupt method, whenever any device needs its service, the
device informs the CPU by sending it an interrupt signal. The CPU
interrupts whatever it is doing and serves the request for service.
• In polling, the CPU continuously monitors a status condition and
Computer Interfacing
8255 Printer
PA D0 – D7
Computer Interfacing
PC7 STROBE
PC6 ACK
16
Printer handshaking signals
18
Inputting data with handshaking
signals (mode 1)
Computer Interfacing
19
Mode 1: I/O with handshaking
signals
• As shown, A and B can be used as output
ports to send data to a device with
handshaking signals.
Computer Interfacing
20
Outputting data with handshaking
signals (mode 1)
Computer Interfacing
21
OBFa (output buffer full for port A)
26
Interrupts vs. polling
• The CPU services various devices. There are two ways for the CPU
to provide service to those devices: interrupts and polling.
• In the interrupt method, whenever any device needs its service, the
device informs the CPU by sending it an interrupt signal. The CPU
interrupts whatever it is doing and serves the request for service.
• In polling, the CPU continuously monitors a status condition and
Computer Interfacing
28
Inputting data with handshaking
signals (mode 1)
Computer Interfacing
29
STB (strobe)
35
Inputting data with handshaking
signals (mode 1)
Computer Interfacing
36
Mode 2: bidirectional I/O with
handshaking
38
Mode 2
8255 Programmable Peripheral
Interface
Features:
•3 8-bit IO ports PA, PB, PC
•PA can be set for Modes 0, 1, 2. PB for 0,1 and PC for mode 0
and for BSR. Modes 1 and 2 are interrupt driven.
•PC has 2 4-bit parts: PC upper (PCU) and PC lower (PCL),
each can be set independently for I or O. Each PC bit can be
Computer Interfacing
39
A1 A0 Select
0 0 PA
0 1 PB
Computer Interfacing
1 0 PC
1 1 Control reg.
40
Computer Interfacing
41
Computer Interfacing
42
BSR mode
Bit set/reset, applicable to PC only. One bit is S/R at a time. Control word:
D7 D6 D5 D4 D3 D2 D1 D0
0 (0=BSR) X X X B2 B1 B0 S/R (1=S,0=R)
D7 D6 D5 D4 D3 D2 D1 D0
Io/m’
gnd o3 LEDS
Cs’ 8255
a7 0 a1 1
Computer Interfacing
a6 1 a0 0
a5 1
Dcr a dcr b
ani ofh jnz back1
Jmp back dcr a
jnz back2
ret
46
3 to 8
Line decoder
Port A
Keys
Io/m’ Port Cl
gnd o3 keys
Cs’ 8255
Port ch
a7 0 a1 1
Computer Interfacing
LEDS
a6 0- a0 0
a5 0 Port B
LEDs
Port address 000 x x x 00 Port A 00h
000 x x x 01 Port B 01h
000 x x x 10 Port C 02h
000 x x x 11 ctrl 03h
47 Command word 1 00 1 0 0 0 1=91h
MODE 1 (Strobed Input/Output). This functional
configuration provides a means for transferring I/O
data to or from a specified port in conjunction with
strobes or “handshaking” signals. In mode 1, port
A and Port B use the lines on port C to generate or
accept these “handshaking” signals.
49
Input Operations
STB (Strobe Interrupt)
STB (Strobed Input). A “low” on this input loads
data into the input latch.
IBF (Input Buffer Full F/F). A “high” on this
output indicates that data has been loaded into the
Computer Interfacing
input latch.
INTE 2 (The INTE Flip-Flop Associated with
IBF). Controlled by bit set/reset of PC4.
50
There are several combinations or modes when not
all of the bits in Port C are used for control or
status. The remaining bits can be used as follows:
If Programmed as Inputs-
All input lines can be accessed
during a normal Port C read.
If programmed as Outputs-
Bits in C upper (PC7-PC4) must be individually
Computer Interfacing
51
Source Current Capability on Port B and Port C
52
Reading Port C Status
53
MODE 1 STATUS WORD FORMAT
D7 D6 D5 D4 D3 D2 D1 D0
I/ I/ I IN IN IN I IN
O O B T T T B T
F EA RA EB F RB
A B
Computer Interfacing
54
D7 D6 D5 D4 D3 D2 D1 D0
O
I I/ I/ IN INT
O INT
B N O O T EB B ERB
FA
T RA F
E B
Computer Interfacing
55
D7 D6 D5 D4 D3 D2
D1 D0
O IN I IN IN
B T B T T
FA E1 F E2 RA
A
Computer Interfacing
56
INTR (Interrupt Request)
INTE A
Controlled by bit set/reset of PC4
INTE B
Controlled by set/reset PC2
57
Computer Interfacing
58
OBF (Output Buffer Full F/F). The OBF output will go
“low” to indicate that the CPU has written data out to the
specified port. The OBF F/F will be set by rising edge of the
WR input being low.
ACK (Acknowledge Input). A “low” on this input informs
the 8255A that the data from port A or port B has been
accepted. In essence, a response from the peripheral device
indicating that it has received the data output by CPU.
INTR (Interrupt Request). A “high” on the output can be
Computer Interfacing
59
Computer Interfacing
60
Combination of MODE 1
Port A and B can be Individually defined as Input
or output in Mode 1 to support a wide variety of
strobed I/O application.
Computer Interfacing
61
Computer Interfacing
62
Control word 1 01 1 0 1 0 0=b4h
BSR word to set INTEA=0 000 100 1=09h
Status word to check obfb’=xxxx xx1x=02h
Mvi a,b4h
Out ffh
Mvi a,09h
Ei
Call print
Lxi h,mem
Mvi c,count
Computer Interfacing
64
MODE 2 Basic Functional Definitions:
•
Used in Group A only.
65
INTR (Interrupt Request). A high on this output
can be used to interrupt the CPU for both input or
output operations.
Output Operations
OBF output will go “low” to
OBF (Output Buffer Full). The
66