5-Interfacing IO Devices - Student Version
5-Interfacing IO Devices - Student Version
DEVICES
1 Iskandar Yahya
[email protected]
03-89216591
INTRODUCTION
Objectives
Parallel and Serial Mode
Identify device/port address of peripheral-mapped
I/O and memory mapped I/O
OUT & IN instructions.
Memory related instructions
Differentiate peripheral-mapped and memory-
mapped I/O
To interface 8085 with other devices
Parallel Vs Serial
Parallel I/O - All 8-bits of data are transferred
3
Data transfer process is identical for both method
Need to understand the foundation I/O operations in
BASIC INTERFACING CONCEPTS
8085’s I/O Data Transfer Process:
-
-
-
-
Things to understand:
How 8085 selects an I/O device?
What hardware chips are necessary?
What software instructions are used?
How data are transferred?
5
PERIPHERAL I/O INSTRUCTIONS
OUT INSTRUCTION
6
PERIPHERAL I/O INSTRUCTIONS
OUT INSTRUCTION
Instruction OUT
M1 (Opcode Fetch) M2 (Memory Read) M3 (I/O Write)
T1 T2 T3 T4 T1 T2 T3 T1 T2 T3
7
PERIPHERAL I/O INSTRUCTIONS
OUT INSTRUCTION
The process:
At First machine cycle M1 -
Place high order memory address 20H on A15-A8
Place low order memory address 50H on AD7-AD0
ALE goes high and IO/M' goes low.
ALE indicates the availability of AD7-AD0 and used
to demultiplex the bus
IO/M' low indicates a memory related operation
At T2, (RD)' (active low) signal is sent and
combined with IO/M' signal to activate the (MEMR)'
signal (active low)
Fetch the instruction code D3 using data bus, 8
decodes it, finds out that it suppose to be 2-byte,
so must read the second byte.
PERIPHERAL I/O INSTRUCTIONS
OUT INSTRUCTION
At the second machine cycle M2 -
Same process as in M1, but this time with the memory
address 2051H
Gets the device port address 01H, second byte of the OUT
instruction
The data remains on the data bus (AD7-AD0) for two T-states
(T2 & T3), before the processor executes the next instruction.9
Therefore we must latch the data bus within the two T-states
before it is lost.
PERIPHERAL I/O INSTRUCTIONS
IN INSTRUCTION
11
PERIPHERAL I/O INSTRUCTIONS
IN INSTRUCTION
The process:
M1 and M2 are identical to OUT instruction.
Questions:
1. When should we enable the latch?
2. What is the address of the latch? 13
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER (OUT)
-
Need to create:
Pulse to indicate the presence of address on
bus
Generate timing pulse to indicate data byte
is on the bus
14
Use both pulse to enable the latch to catch
the data
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER (OUT)
A7
Data Bus Latch
or To Peripherals
Decod (D7 – D0)
Address Lines Buffer
A7 – Ao er
A0
AND Enabl
e
Device Select
Control Signal Pulse
or
16
Example of a practical decoding circuit (Device
address 01H)
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER
Absolute Decoding
All eight address lines are decoded to
generate unique pulse
Figure shows unique pulse will be generated
if and only if address 01H (ooooooo1) is on
the address bus
Good design practice
Partial Decoding
Only some of the address lines are decoded, device
has multiple addresses
Figure below shows A1 and A0 are omitted (don’t care
states)and replaced by IO/M' and (WR)',
So device has the addresses 00H, 01H, 02H, and 03H
Less components
A7 A6 A5 A4 A3 A2 A1 A0 (Don’t Puls
care) e
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0
19
0 0 0 0 0 0 1 1
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER (OUT)
Decoding circuit
implemented using Partial
Decoding technique
20
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER (IN)
21
Input Interfacing: Example circuit
PERIPHERAL I/O INSTRUCTIONS
DEVICE SELECTION & DATA TRANSFER (IN)
Input Interfacing
Example of 8-Key input port. Basic concept is the same
as output
The process:
Address line connected to 8-inout NAND gate.
When address is FFH, NAND out put goes low and
combined with (IOR)' in gate G2
G2 generate device select pulse used to enable tri-
state buffer
Data from keys are put on the data bus D7-D0 and
loaded onto the accumulator
O0 0 1 0 1 1 1 1 1 0 1 1
O1
I0 O2 0 1 1 1 1 1 1 0 1 1 1
3-to-8
I1 O3
O4 1 0 0 1 1 1 0 1 1 1 1
I2 O5 1 0 1 1 1 0 1 1 1 1 1
O6
O7 1 1 0 1 0 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1
23
PERIPHERAL I/O INSTRUCTIONS
INTERFACING I/OS USING DECODERS
24
Another scheme of address decoding. Use 3-to-8 demux
(decoder) and4-input NAND to decode address bus
PERIPHERAL I/O INSTRUCTIONS
INTERFACING I/OS USING DECODERS
This is how the circuit work:
3-to-8 decoder has 3 inputs, 3 enable pins and 8
outputs
For the decoder to be functional, all the enable
switches must be active, i.e. E1' = 0 (active low),
E'2 = 0 (active low) and E'3 = 1 (active high)
Addresses lines A2, A1 and A0 are used as
inputs, therefore we can have 8 different output
device or port addresses. (2^3 = 8)
A7-A3 are used to enable the encoder
Combine the decoded signal with the appropriate
control signal to generate I/O select pulse
Here, O0 is logically ANDed with (IOW)' signal to
select the output port for output operation 25
O2 is logically NAND with (IOR)' to select the tri-
state buffer for input operation
PERIPHERAL I/O INSTRUCTIONS
INTERFACING I/OS USING DECODERS
Interesting Question:
Can an input port and an output port have the same
port address?
Answer:
Problem:
29
INTERFACING OUTPUT DISPLAY
EXAMPLE: SEVEN SEGMENT OUTPUT DISPLAY AS AN
OUTPUT DEVICE
Solution:
Seven-Segment LED
Interfacing circuit:
For output port with address F5H, the address lines
A7-A0 should have the following logic:
A7 A6 A5 A4 A3 A2 A1 A0
32
INTERFACING OUTPUT DISPLAY
EXAMPLE: SEVEN SEGMENT OUTPUT DISPLAY AS AN
OUTPUT DEVICE
Instructions:
;Load seven-segment code in the
accumulator
;Display digit 7 at port F5H
;End
34
INTERFACING INPUT DEVICES
EXAMPLE: DATA INPUT FROM DIP SWITCH
From Figure:
Tri-state octal buffer is used as an interfacing device
controlled by active low signals (OE)'
If (OE)' is low, the keyed data shows up at the data bus
Interfacing circuit:
All low-order address lines, except A4 and A3, are
connected to the decoder
A4 and A3 are don’t care lines
35
|--Enable Lines -------| |- Don’t care -| |------- Input --------|
INTERFACING INPUT DEVICES
EXAMPLE: DATA INPUT FROM DIP SWITCH
(IOR)' is generated by ANDing IO/M' and (RD)'
(IOR)' is ANDed with output of decoder to produce select
pulse to enable the tri-state buffer
Once the tri-state buffer is enabled, the logic levels of
the switches i.e. keyed data is placed on the data bus,
before placed into the accumulator
Closed switch = logic "0"
Open switch = logic "1"
Input reading is F8H
36
INTERFACING INPUT DEVICES
EXAMPLE: DATA INPUT FROM DIP SWITCH
A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 0 1 0 0
1 0 0 0 1 1 0 0
1 0 0 1 0 1 0 0
1 0 0 1 1 1 0 0
37
MEMORY MAPPED I/O
In memory-mapped I/O, the devices are
assigned and identified by 16-bit addresses
Instructions used:
LDA*
STA*
-
-
-
Control signals used: (MEMR)' and (MEMW)'
This technique is similar to peripheral
I/O
38
*-
MEMORY MAPPED I/O
Memory Machine Mnemonic Comments
Address Code s ; Store Contents of
accumulator in memory
location 8000H
40
MEMORY MAPPED I/O
DATA TRANSFER INSTRUCTIONS
Essentially the same as using IN and Out instructions
But memory-mapped uses 16-bit addressing,
therefore needs 4 machine cycles, instead of 3 as in
the time diagram