Eee 342 11 Io
Eee 342 11 Io
Eee 342 11 Io
Interfacing
EEE 342
1/20/23 2
Motivation
1/20/23 3
Isolated vs. Memory Mapped
There are two different methods to interface I/O to
the microprocessor:
Isolated I/O: uses the dedicated I/O instructions
(IN, OUT and INS, OUTS) and has its own address
space for I/O ports (0000H-FFFFH)- isolated from
the memory address space
The addresses for isolated I/O devices are called ports and
are separate from memory
Memory mapped I/O: uses memory reference
instructions , e.g. MOV, and a region of the memory
address map. So address space is shared between
memory and I/O (used by only one of them)
1/20/23 4
Isolated vs. Memory Mapped
Both techniques can be used with Intel processors But
most Intel-based systems e.g. the PC, use isolated I/O
1/20/23 5
I/O Port specified
Memory and I/O address Memory:
Memory:
Maps for the 8086/8088 MOV
in DX, either
MOV explicitly or implicitly
I/O:
a. Isolated I/O I/O:
IN
1/20/23 6
What is port?
As with memory, I/O devices have I/O addresses
(addresses for the I/O port)
1/20/23 9
Memory Mapped I/O
It uses any instruction that transfers data between the
microprocessor and memory. A memory-mapped I/O
device is treated as memory location in the memory
map.
Advantage. The main advantage of memory-mapped I/O
is that any memory transfer instruction can be used to
access the I/O device.
1/20/23 10
I/O Instructions
Two type of instructions are used
1/20/23 11
IN & OUT I/O Instructions
When we use 8 bit fixed port address, the address
appears on A7-A0 while A15-A8 remains 0. The A19-
A16 are undefined.
For 16 bits the address A15-A0 appears on
address bus.
1/20/23 12
IN & OUT I/O Instructions
1/20/23 13
I/O Data widths
As with memory, I/O ports are also organized as bytes
A port can be 1, 2, or 4 bytes wide (not 8 bytes wide on
the Pentium)
00F3H
Port is 4 bytes wide
00F2H
EAXPort is 2 bytes wide
00F1H
AX Port is 1 byte wide
Port Address p8 00F0H LS byte AL
IN & OUT I/O Instructions
OUT It (I/O Write): Copies the contents of the
accumulator out to an external I/O device
1/20/23 15
The PC I/O
The PC I/O space
Address Space
Processor communicates
with and controls these
peripherals through writing
into/reading from their
control registers accessed
as I/O locations 03FF
Must use 16-bit variable
I/O address in register DX
17
Basic input port( for I/O read)
The basic input port connects an external set of
bits to the mP data bus whenever the mP executes
the correct IN instruction with the correct I/O
port address
External device puts data on the mP data bus
Must include a 3-state (Tri-State) buffer to
limit access to the processor data bus to the
duration of executing the I/O instruction only
1/20/23 18
74LS244 Tri-state buffer
I0 O0
I1 O1
I2 O2
I3 O3
74LS244
I4 O4
I5 O5
I6 O6
I7 E1 E2 O7
1/20/23 19
Tri-state buffer ?
If the "enable" inputs signal is true, the tri-
state buffer behaves like a normal buffer.
If the "enable“ or “control” input signal is
0, the tri-state buffer passes a high
impedance (or hi-Z) signal, which
effectively disconnects its output from the
circuit.
1/20/23 20
Tri-state buffer ?
1/20/23 21
Interfacing an Input Port
74LS244
D0 O0 I0
RD’
WR’
IO/M’
1/20/23 22
Basic 8-bit Input Interface:
Fundamentals
Reads the status of 8 toggle
Switches (a byte read)
Pull-up
Resistors To mP
Gate
0 1
Toggle switches
Outputs:
3-state buffer
The SEL signal is generated (active low) Normally Hi-Z
By decoding: Unless device is
- The address for the I/O port Selected
- The
1/20/23I/O READ operation
(both G1 and G2
23
low
Basic Output port( for I/O read)
The basic output port writes data from the mP
data bus to an output port whenever the mP
executes the correct OUT instruction with the
correct I/O port address
Must latch the processor data put on the bus
during the I/O instruction to make it available
indefinitely for the port
No need for 3-state (Tri-State) buffers as the data
bus is at the input side of the latch
1/20/23 24
74LS374 8-bit parallel register
D0 O0
D1 O1
D2 O2
D3 O3
74LS374
D4 O4
D5 O5
D6 O6
D7 CLK OE O7
1/20/23 25
Interfacing an Output Port
74LS374
D0 D0 O0
RD’
WR’
IO/M’
1/20/23 26
Basic 8-bit Output Interface:
Basic Output port( for I/O read)
Controls 8 LEDs (1: OFF, 0: ON)
1/20/23 28
I/O Port interfacing
Most embedded systems use only fixed I/O addressing:
- i.e. Only the least significant eight address bits A7-A0
are decoded. Limits number of I/O ports to 256 (enough)
1/20/23 29
Address Decoding for 8 I/O Ports: F0 to F7
Using a Decoder IC for the 8088 using 8-bit I/O address
Decoder O/Ps
LS part Decoder I/Ps
X
X
(Select port X
X
on decoder) X
X
0
1 To ‘Enable’
1
0 Inputs on the
8 I/O ports
S part
nable decoder)
1
1 3-to-8 A7 …....A0
1
1
1 Decode 11110 000 = F0 1st
1 r 11110 001 = F1 2nd
Address from mP …………………….
11110 111 = F7 7th
Note: #IO/M decoding should be added
1/20/23 30
Hand Shaking
The parallel port is an example of interfacing
slow devices, e.g. a printer, to the processor
Strobe Data
nto Printer
Data
1/20/23 32
Parallel Port
Processor polls
‘Busy’ to see if
If (BUSY == 0) (printer not busy), so processor can send
the data for next character
Else
Poll again
1/20/23 33