2. Programmable Interface
Devices
Programmable Interface Device
used to interface a I/O device to the microprocessor
It is a multifunction device designed to use in minimum
mode system
It contain RAM, I/O ports and Timer
8085
Programmable
I/O
Interface
I/O
Devices
System Bus
3. Requirement for PPI
I/P & O/P Regs: A group of latches to
hold data
Tri-State Buffer
Capability of Bidirectional data flow
Handshake & Interrupt signal
Control Logic
Chip Select Logic
Interrupt control logic
4. 8155 – A multipurpose
programmable interface
Designed to be compatible with 8085
It includes
◦ 256 bytes of Read/Write memory
◦ Three I/O ports
Port A (8-bit)
Port B (8-bit)
Port C (6-bit)
◦ A 14-bit timer
◦ Internal address latch to Demux AD0-
AD7, using ALE line
5. Block Diagram - 8155
256 X 8
Static
RAM
A
B
CTimer
8
8
6
Port A
Port B
Port C
PA0-7
PB0-7
PC0-5
8AD0-7
IO/M
CE
ALE
RD
WR
Timer CLK
TIMER OUT
Vcc (+5 V)
Vss (0 V)
RESET
I/ODevices
8085
9. Programming 8155
8155 is a Programmable Peripheral
Interface
8085 can send data to 8155 using
data bus
This data can be
◦ For I/O devices connected to 8155
◦ Timer registers of 8155
◦ Instruction/Command word for 8155
Commands for 8155 are stored in a 8-
bit Control Register inside 8155
10. Program
MVI A,01 H ; Set Do=1, D1-D7==0
OUTFFH ;Write in control register
MVI A,BYTE1 ;Load data bye
OUTFEH ; Send Data out
7A
0A
DIR
G: Enable
7B
0B
Control
Reg
D0
D1
D7A7
A6
A5
A4
A3
A2
A1
A0
11. 3 to 8
Decoder
CWR
Port
A
Port
B
Port
C
Timer
MSB
LSB
Latch
Clock for timer
PA0-PA7
PB0-
PB7
PC0-
PC5
Timer
Out
A0
A1
A2
ALE
AD0-AD7
A0-A7
D7-D0
0
1
2
3
4
5
CEb
A2 A
1
A0 Port (ALE
high,
AD0=A0)
0 0 0 Command
/Status
Register
0 0 1 PA
0 1 0 PB
0 1 1 PC
1 0 0 Timer LSB
1 0 1 Timer MSB
12. 3 to 8
Decoder
04
A13
A12
A11
A15
A14
A2
A1
A0
5
V
3 to 8
Decoder
RAM
Cont
rol
CWR
Port
A
Port
B
Port
C
Timer
MSB
LSB
Latc
h
Clock for timer
PA0-
PA7
PB0-
PB7
PC0-
PC5
Timer
Out
Reset in
RD
WR
A0
A1
A2
ALE
C
E
IO/M
IO/
M
AD0-AD7
A0-
A7
D7-
D0
20H
21H
22H
23H
24H
25H
CS
13. What type of Commands can be
given to 8155?
To configure the I/O ports as Input or
Output
To start/stop timer etc.
To use handshake mode or not
14. Control word for 8155
A command/instruction for 8155 is also
called control word
This control word is written to control
register of 8155
Control word of 8155 is of 8-bits
15. Control Word Definition for
8155
D0
D1
D2
D3
D4
D5
D6
D7
D3 D2 PORT C
0 0 ALT1
0 1 ALT2
1 0 ALT3
1 1 ALT4
D7 D6 Timer
0 0 NOP
0 1 Stop
1 0 Stop
after TC
1 0 Start
Port A
Port B
0, Input
1, Output
Port C
Interrupt Enable Port A
Interrupt Enable Port B
0, Disable
1, Enable
Timer
16. I/O functions of Port C
ALT D3 D2 PC5 PC4 PC3 PC2 PC1 PC0
ALT1 0 0 I I I I I I
ALT2 0 1 O O O O O O
ALT3 1 0 O O O STBA BFA INTRA
ALT4 1 1 STBB BFB INTRB STBA BFA INTRA
I = Input O = Output
STB = Strobe BF = Buffer Full INTR = Interrupt Request
17. The 8155 timer consists of two 8-bit registers.
1. 8-bit LSB and 8-bit MSB.
2. In these 16 bits, 14 bits are used for counter and two bit for
mode selection.
3. The counter is a 14 bit down counter. It can operate in 4
different modes of operation.
We can select mode using two bits M2 and M1
00(Mode 0)- Single Square Wave
01(Mode 1)- Square Wave
10(Mode 2)- Single Pulse on TC(terminal count)
11(Mode 3)- Pulse every TC
18. Mode 0: In this mode, timer gives only one cycle of
square wave, the output remains high for 1/2 count
and remain s low for 1/2 count. If count is odd it
remains high for (n+1)/2 and low for (n-1)/2. Where n
is count value. Wave width depends on two factor: one
is Input clock pulse frequency, and the other is count
loaded in counter.
Mode 1: This mode is similar to single square wave in
operation but the when counter becomes zero, the
count value is automatically reloaded. Thus it provides
continuous square wave.
19. Mode 2: This mode gives a single clock pulse as a
output of the end of the count The output is high
normally, but it becomes low for 1 clock pulse and
again it will become high and remain high.
Mode 3: This mode is similar to mode 2 but when the
counter becomes zero the count value is
automatically reloaded. Thus it provides continuous
pulses.
20. Design an interfacing circuit to read data from an A/D
converter using the 8155A in the peripheral mapped I/O.
(Example)
8085
3-to-8 Decoder
A/D
Converter
Analog
Input
Digital
Input
P
o
r
t
A
AD0-AD7
O0O7
8155
P
o
r
t
C
P
o
r
t
B
SOC
OE
EOCO2
CE
E2
E1
A2
A1
A0A11
A12
A13
A14
A15
IO/M
RD
WR
RESET
ALE
LED
Display
BFA
STBA
PC5
21. Port Addresses of 8155
A2 A1 A0 Port
0 0 0 Control/Status
Register
0 0 1 Port A
0 1 0 Port B
0 1 1 Port C
1 0 0 LSB Timer
1 0 1 MSB Timer
Chip Selection
A7 A6 A5 A4 A3
0 0 0 1 0
= 10H
= 11H
= 12H
= 13H
= 14H
= 15H
22. Application Programming
Logic
1. Configure 8155
2. 8085 sends SOC command to ADC
3. 8085 communicates with ADC
using PortC in handshake mode
4. 8085 reads 8-bit temperature value
from port A
5. 8085 displays the temperature
value on the LED display
23. 1. Configure 8155 I/O Ports
Port A as INPUT port
Port B as OUTPUT
port
Port C in ALT3 mode
ALT D3 D2 PC5 PC4 PC3 PC2 PC1 PC0
ALT3 1 0 O O O STBA BFA INTRA
SOC EOC OE
24. Control Word for configuration
D0
D1
D2
D3
D4
D5
D6
D7
D3 D2 PORT C
0 0 ALT1
0 1 ALT2
1 0 ALT3
1 1 ALT4
D7 D6 Timer
0 0 NOP
0 1 Stop
1 0 Stop
after TC
1 0 Start
Port A
Port B
0, Input
1, Output
Port C
IE Port A
IE Port B
0, Disable
1, Enable
Timer
0
1
0
1
0
0
0
0
25. Program Instructions for configuration
Data
◦ Control word : 0AH
Port Address
◦ Address of Control register : 10H
Instructions
◦ MVI A, 0AH
◦ OUT 10H
26. 2. 8085 sends SOC command to
ADC
A small duration pulse on SOC input of
ADC will start conversion process
SOC input of ADC is connected to port
pin PC5 of Port C (Port address 13H)
Data
◦ Data value 20H followed by 00H
ALT D3 D2 PC5 PC4 PC3 PC2 PC1 PC0
ALT3 1 0 O O O STBA BFA INTRA
SOC
1 0 0 0 0 0
28. 3. 8085 communicates with ADC
using Port C in handshake mode
Port A used to input 8-bit data from
ADC
Port C used for handshakingALT D3 D2 PC5 PC4 PC3 PC2 PC1 PC0
ALT3 1 0 O O O STBA BFA INTRA
EOC OE
29. ADC resets EOC to LOW at end of
conversion
8155 sets BF to 1 to enable ADC output
latch
8085 is waiting for BF to be SET to 1 and
◦ Reads port A by making RD signal active (0)
At the end of read cycle RD goes HIGH
(1)
This resets BF signal to 0.
8085 waits for BF signal to be RESET
and
◦ starts conversion process again
30. 8085 is waiting for BF
To know the status of BF signal 8085
reads status register of 8155
Status register shares same address as
control register
X Timer INTEB BFB INTRB INTEA BFA INTRA
D7 D6 D5 D4 D3 D2 D1 D0
Status Word Definition
31. Program Instructions
8085 reads status register
◦ Address of status register : 10H
◦ Reads port A if BFA = 1
◦ Output temperature on port B
Status: IN 10H
ANI 02H
JZ Status
IN 11H ;Step -4 Reads temperature value
OUT 12H ; Step –5 display on
32. 8085 reads status register
◦ Address of status register : 10H
◦ Starts conversion again if BFA = 0
Again: IN 10H
ANI 02H
JNZ Again
JMP Start
33. Complete Program
MVI A, 0AH
OUT 10H
Start: MVI A, 20H
OUT 13H
MVI A, 00H
OUT 13H
Status: IN 10H
ANI 02H
JZ Status
IN 11H
OUT 12H
Again: IN 10H
ANI 02H
JNZ Again
JMP Start
Configure 8155
Start Conversion
Read Status register
Wait till BFA = 1
Read temperature value
Display on LED
Read status register
Wait till BFA = 0
Start Conversion again
35. Port Address
◦ Control Register=20H, Port A= 21H, Port B= 22H
Control word:
Program
◦ MVI A,03 ; initialize Port A &B for O/P
◦ OUT 20H
◦ MVI A, BYTE1 ; Display BYTE1 at port A
◦ OUT 21H
◦ MVI A, BYTE2 ; Display BYTE2 at port B
◦ OUT 22H
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 1 1
Timer Not
Applicable
Use for
Port C
Port B
Output
Port A
Output