CSE491 Computer Interfacing and Peripherals Lec7 Handsout
CSE491 Computer Interfacing and Peripherals Lec7 Handsout
Part Two
CSE 491
82C55
Computer Interfacing and Peripherals
programmable peripheral interface
(PPI)
2 4
11/8/2024
• The 82C55 (CMOS version) requires wait states if Basic Description of the 82C55
operated with a processor using higher than an 8
MHz clock. • Fig 1 shows pin-outs of the 82C55 in
DIP and surface mount (flat pack) format.
– also provides at least 2.5 mA of sink (logic 0)
current at each output, a maximum of 4.0 mA • The three I/O ports (labeled A, B, and C) are
programmed as groups.
• Because I/O devices are inherently slow, wait states
used during I/O transfers do not impact significantly – group A connections consist of port A (PA7–PA0)
upon the speed of the system. and the upper half of port C (PC7–PC4)
• The 82C55 still finds application even in the latest – group B consists of port B (PB7–PB0) and the
Core2-based computer system. lower half of port C (PC3–PC0)
• 82C55 is selected by its CS pin for programming and
reading/writing to a port.
5 7
6 8
11/8/2024
Figure 2 The 82C55 interfaced to the low bank of the 80386SX microprocessor.
• Table 1 shows I/O port assignments used for
programming and access to the I/O ports.
• In the PC, a pair of 82C55s, or equivalents, are
decoded at I/O ports 60H–63H and also
at ports 378H–37BH.
• The 82C55 is a fairly simple device to interface to
the microprocessor and program.
• For 82C55 to be read or written, the CS input must
be logic 0 and the correct I/O address must be
applied to the A1 and A0 pins.
• Remaining port address pins are don’t cares.
9 11
• Fig 2 shows an 82C55 connected to the 80386SX • After a RESET, no other commands are needed, as
so it functions at 8-bit addresses C0H (port A), C2H long as it is used as an input device for all three
(port B), C4H (port C), ports.
and C6H (command register). • 82C55 is interfaced to the PC at port addresses
– this interface uses the low bank of the I/O map 60H–63H for keyboard control.
• All 82C55 pins are direct connections to the – also for controlling the speaker, timer, and other
80386SX, except the CS pin. The pin is internal devices such as memory expansion
decoded/selected by a 74ALS138 decoder. • It is also used for the parallel printer port at I/O ports
• A RESET to 82C55 sets up all ports as 378H–37BH.
simple input ports using mode 0 operation.
– initializes the device when the processor is reset
10 12
11/8/2024
Programming the 82C55 • Group A (port A and the upper part of port C) are
programmed as input or output pins.
• 82C55 is programmed through two internal
command registers shown in Figure 3. • Group A can operate in modes 0, 1, and 2.
• Bit position 7 selects either command byte A or – mode 2 operation is a bidirectional mode of
command byte B. operation for port A
– command byte A programs functions of group • If a 0 is placed in bit position 7 of the command byte,
A and B command byte B is selected
– byte B sets (1) or resets (0) bits of port C only • This allows any bit of port C to be set (1) or reset
if the 82C55 is programmed in mode 1 or 2 (0), if the 82C55 is operated in either mode 1 or 2.
– otherwise, this byte is not used for programming
• Group B (port B and the lower part of port C) are
programmed as input or output pins.
13 15
Figure 3 The command byte of the command register in the 82C55. (a) Programs
ports A, B, and C. (b) Sets or resets the bit indicated in the select a bit field.
Mode 0 Operation
14 16
11/8/2024
• Resistor values in Fig 4 are chosen so the segment An LCD Display Interfaced to the 82C55
current is 80 mA.
– required to produce average 10 mA current
per segment as the displays are multiplexed • LCDs (liquid crystal displays) have replaced LED
• A six-digit display uses a segment current of 60 mA displays in many applications.
for an average of 10 mA per segment. • Fig 5 shows an Optrex DMC-20481 LCD display
• Peak anode current in an eight-digit display interfaced to an 82C55.
is 560 mA (seven segments 80 mA). – DMC-20481 is a 4-line by 20-characters-per-line
– average anode current is 80 mA display that accepts ASCII code as input data
• In a six-digit display, peak current would be 420 mA • It also accepts commands that initialize it and control
(seven segments 60 mA). its application.
18 20
11/8/2024
21 23
• The data connections, which are attached to the • Initialization is accomplished via the following:
82C55 port A, are used to input display data and to – 1. Wait at least 15 ms after VCC rises to 5.0 V
read information from the display. – 2. Output the function set command (30H), and
• For a 4-bit interface, D4–D7 pins are used where the wait at least 4.1 ms
data must be formatted with the high nibble first, – 3. Output the function set command (30H) a
followed by the low nibble. second time, and wait at least 100 µs
• A few newer OLED devices contain a serial interface – 4. Output the function set command (30H) a
that uses a single pin for the data. third time, and wait at least 40 µs
– 5. Output the function set command (38H) a
fourth time, and wait at least 40 µs
– 6. Output 08H to disable the display, and wait
at least 40 µs
22 24
11/8/2024
– 7. Output a 01H to home the cursor and clear • Once the BUSY procedure is available, data can be
the display, and wait at least 1.64 ms sent to the display by writing another procedure
– 8. Output the enable display cursor off (0CH), called WRITE.
and wait at least 40 µs • The WRITE procedure uses BUSY to test before
– 9. Output 06H to select auto-increment, shift trying to write new data to the display.
the cursor, and wait at least 40 µs • Example 11–14 shows the WRITE procedure, which
transfers the ASCII character from the BL register to
• Software to accomplish the initialization of
the current cursor position of the display.
the LCD display is listed in Example 11–12.
• The time delays can also be obtained by using a
timer in C++.
25 27
• After initialization, time delays are no longer needed • The only other procedure needed for a basic display
when sending data or many commands to the is the clear & home cursor procedure, called CLS,
display. shown in Example 11–15.
• The clear display command still needs a time delay • This procedure uses the SEND macro from the
as the busy flag is not used . initialization software to send the clear command to
• Instead of a time delay, the busy flag is tested to see the display.
whether the display has completed an operation. • With CLS and the procedures presented thus far,
• The BUSY procedure tests the LCD display and only you can display any message on the display, clear
returns when the display has completed a prior it, display another message, and basically operate
instruction. the display.
26 28
11/8/2024
Figure 6 The stepper motor showing full-step operation: (a) 45° (b) 135° (c) 225°
A Stepper Motor Interfaced to the 82C55. (d) 315°.
29 31
• In all cases, these steps are gained through many • The motor is driven by NPN Darlington amp pairs to
magnetic poles and/or gearing. provide a large current to each coil.
• Figure 6 shows a four-coil stepper motor that uses • A circuit that can drive this stepper motor is
an armature with a single pole. illustrated in Fig 7.
– two coils are energized – with the four coils shown in place
• If less power is required, one coil may be energized • This circuit uses the 82C55 to provide drive signals
at a time, causing the motor to used to rotate the motor armature in either the right-
step at 45°, 135°, 225°, and 315°. or left-hand direction.
• The motor is shown with the armature rotated to four • A simple procedure that drives the motor is listed in
discrete places, called full stepping. Example 11–16 in both assembly language and as a
– accomplished by energizing the coils, as shown function in C++.
30 32
11/8/2024
Figure 7 A stepper motor interfaced to the 82C55. This illustration does not show the Figure 8 A 4 4 keyboard matrix connected to an 8088 microprocessor through the
decoder. 82C55 PIA.
33 35
34 36
11/8/2024
Figure 10 Strobed input operation (mode 1) of the 82C55. (a) Internal structure and
• The ShortDelay procedure is needed as the (b) timing diagram.
computer changes port B at a very high rate .
– the time delay allows the data sent to port B to
settle to their final state
• This is not needed if scan rate (time between output
instructions) does not exceed 30 KHz.
– if the scanning frequency is higher, the device
generates radio interference
• If so, the FCC will not approve application
in any accepted system
– without certification the system cannot be sold
37 39
38 40
11/8/2024
• Interrupt request is an output that requests an • An example of a strobed input device is a keyboard.
interrupt. The INTR pin becomes a logic 1 when STB • The keyboard encoder debounces the key switches
returns to a logic 1. Cleared when data are input and provides a strobe signal whenever a key is
from the port by the processor. depressed.
– the data output contains ASCII-coded key code
INTE • Figure 11 illustrates a keyboard connected to
• Interrupt enable signal is neither input nor output; it strobed input port A.
is an internal bit programmed via
port PC4 (port A) or PC2 (port B) bit position.
41 43
42 44
11/8/2024
45 47
Figure 12 Strobed output operation (mode 1) of the 82C55. (a) Internal structure and
(b) timing diagram. ACK
• The acknowledge signal causes the OBF
pin to return to logic 1. The ACK signal is a response
from an external device, indicating that it has
received data from the 82C55 port.
INTR
• Interrupt request often interrupts the processor
when the external device receives the data via the
ACK signal. Qualified by the internal INTE (interrupt
enable) bit.
46 48
11/8/2024
Figure 13 The 82C55 connected to a parallel printer interface that illustrates the
INTE strobed output mode of operation for the 82C55.
PC4, PC5
• Port C pins PC4 and PC5 are general-purpose I/O
pins. The bit set and reset command is used to set or
reset these two pins.
49 51
• The printer interface demonstrates how to achieve • Mode 2 is allowed with group A only.
strobed output synchronization between the printer • Port A becomes bidirectional, allowing data
and the 82C55. transmit/receive over the same eight wires.
• Figure 13 illustrates port B connected to – useful when interfacing two computers
a parallel printer, with eight data inputs for receiving • Also used for IEEE-488 parallel high-speed GPIB
ASCII-coded data, a DS (data strobe) input to (general- purpose instrumentation bus) interface
strobe data into the printer, and an ACK output to standard.
acknowledge the receipt of the ASCII character.
• Figure 14 shows internal structure and timing for
mode 2 bidirectional operation.
50 52
11/8/2024
Figure 14 Mode 2 operation of the 82C55. (a) Internal structure and (b) timing
diagram. ACK
• Acknowledge is an input that enables the three-
state buffers so that data can appear on port A. If
ACK is logic 1, the output buffers of port A are at
their high-impedance state.
STB
• The strobe input loads the port A input latch with
external data from the bidirectional port A bus.
53 55
OBF
• Output buffer full is an output indicating the output
buffer contains data for the bidirectional bus.
54 56
11/8/2024
57 59
The Bidirectional Bus • The INTR (interrupt request) pin can be activated
from both directions of data flow through the bus.
• The bidirectional bus is used by referencing port A
with the IN and OUT instructions. • If INTR is enabled by both INTE bits, the output and
input buffers both cause interrupt requests.
• To transmit data through the bidirectional bus, the
program first tests to determine whether the output • This occurs when data are strobed into the buffer
buffer is empty. using STB or when data are written using OUT.
– if so, data are sent to the output buffer via OUT
• The external circuitry also monitors the signal to
decide whether the microprocessor has sent data to
the bus.
58 60
11/8/2024
61 63
62 64