Professional Documents
Culture Documents
Interfacing
Chapter 6:
Interfacing Examples
Objectives
At the end of this Chapter, students must be
able to interface an 8051 uC to:
Hex Keypad
LCD
External Memory
7-segment LED
8-bit ADC and DAC
8255 PPI
Definition
The interconnection, or linkage, between the microcontroller
with external devices is called interfacing.
Generally, an interface is a shared boundary between two or
more devices which involves sharing of information.
Other considerations in interfacing include synchronization,
direction of data transmission, and sometimes the
adjustment of signal levels or modes.
Address, data and control buses play an important role in
linking the parts of the system together.
Real-World Interfacing
Seven
Segment
8051
LCD
Display
ADC
DAC
Hex
Keypad
ROM
RAM
Ex Memory
I/O devices
Peripheral devices (also called I/O devices) are pieces of
equipment that exchange data with a CPU
Examples: switches, LED, CRT, printers, keyboard, keypad
Speed and characteristics of these devices are very
different from that of CPU so they cannot be connected
directly
Interface chips are needed to resolve this problem
Main function of an interface chip is to synchronize data
transfer between CPU and I/O device
Data pins of interface chip are connected to CPU data bus
and I/O port pins are connected to I/O device
Processor talks to both memory and peripherals using same bus two ways to
talk to peripherals
Memory-mapped I/O
Peripheral registers occupy addresses in same address space as memory
e.g., Bus has 16-bit address
lower 32K addresses may correspond to memory
upper 32k addresses may correspond to peripherals
Standard I/O (I/O-mapped I/O)
Additional pin (M/IO) on bus indicates whether a memory or peripheral
access
e.g., Bus has 16-bit address
all 64K addresses correspond to memory when M/IO set to 0
all 64K addresses correspond to peripherals when M/IO set to 1
ECP2036 Microprocessor and Interfacing
Compromises/extensions
Parallel I/O peripheral
Processor
Memory
System bus
Port A
Port B
Port C
Port 0
Port 1
Port 2
Port 3
Parallel I/O peripheral
10
11
12
13
14
Methods used to synchronize data transfer between interface chip and I/O
devices:
1. Brute force method:
- interface chip returns voltage levels in its input ports to CPU and makes
data written by CPU directly available on its output ports
- All 8051 port can perform brute force I/O
2. Strobe method:
- During input, the I/O device activates a strobe signal when data are stable.
Interface chip latches the data
- For output, interface chip places output data on output port. When data is
stable, it activates a strobe signal. I/O device latches the data
3. Handshake method: two handshake signals are needed
- One is asserted by interface chip and the other by I/O device
15
Handshaking
A hardware method that can be used to achieve
synchronization is to use input/output lines, termed
handshake lines, between the microprocessor and the
peripheral to control the timing of data transfers; the
process is termed handshaking.
Handshaking usually uses two additional hardware lines,
one is called strobe and the other is called
acknowledge. The sender provides the signal to the
strobe line and the receiver provides the signal to the
acknowledge line.
ECP2036 Microprocessor and Interfacing
16
17
1.
2.
3.
18
1.
2.
3.
19
WAIT
..
ORL
..
CLR
SETB
JNB
..
P1
P3.0
P3.1
P3, #03H
STROBE
STROBE
ACK, WAIT
20