S11 Basic IO Interface-II
S11 Basic IO Interface-II
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The 82C55 (CMOS version) requires wait states if operated with a processor using higher than an 8 MHz clock.
also provides at least 2.5 mA of sink (logic 0) current at each output, a maximum of 4.0 mA
Because I/O devices are inherently slow, wait states used during I/O transfers do not impact significantly upon the speed of the system. The 82C55 still finds application even in the latest Core2-based computer system.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
82C55 is used for interface to the keyboard and parallel printer port in many PCs.
found as a function within an interfacing chip set also controls the timer and reads data from the keyboard interface
An experimentation board is available that plugs into the parallel port of a PC, to allow access to an 8255 located on the board. The 8255 is programmed in either assembly language or Visual C++ through drivers available with the board.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1118 The pin-out of the 82C55 peripheral interface adapter (PPI).
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Table 112 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 60H63H and also at ports 378H37BH. 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 dont cares.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Fig 1119 shows an 82C55 connected to the 80386SX so it functions at 8-bit addresses C0H (port A), C2H (port B), C4H (port C), and C6H (command register).
this interface uses the low bank of the I/O map
All 82C55 pins are direct connections to the 80386SX, except the CS pin. The pin is decoded/selected by a 74ALS138 decoder. A RESET to 82C55 sets up all ports as simple input ports using mode 0 operation.
initializes the device when the processor is reset
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1119 The 82C55 interfaced to the low bank of the 80386SX microprocessor.
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
After a RESET, no other commands are needed, as long as it is used as an input device for all three ports. 82C55 is interfaced to the PC at port addresses 60H63H for keyboard control.
also for controlling the speaker, timer, and other internal devices such as memory expansion
It is also used for the parallel printer port at I/O ports 378H37BH.
10
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Group B (port B and the lower part of port C) are programmed as input or output pins.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
11
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1120 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.
group B operates in mode 0 or mode 1 mode 0 is basic input/output mode that allows the pins of group B to be programmed as simple input and latched output connections Mode 1 operation is the strobed operation for group B connections data are transferred through port B handshaking signals are provided by port C
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
12
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Group A (port A and the upper part of port C) are programmed as input or output pins. Group A can operate in modes 0, 1, and 2.
mode 2 operation is a bidirectional mode of operation for port A
If a 0 is placed in bit position 7 of the command byte, command byte B is selected This allows any bit of port C to be set (1) or reset (0), if the 82C55 is operated in either mode 1 or 2.
otherwise, this byte is not used for programming
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
13
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 0 Operation
Mode 0 operation causes 82C55 to function:
as a buffered input device as a latched output device
Fig 1121 shows 82C55 connected to a set of eight seven-segment LED displays. These are standard LEDs.
the interface can be modified with a change in resistor values for an organic LED (OLED) display or high-brightness LEDs
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
14
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1121 An 8-digit LED display interfaced to the 8088 microprocessor through an 82C55 PIA.
ports A & B are programmed as (mode 0) simple latched output ports port A provides segment data inputs port B provides a means of selecting one display position at a time for multiplexing the displays the 82C55 is interfaced to an 8088 through a PLD so it functions at I/O port numbers 0700H0703H PLD decodes the I/O address and develops the write strobe for the WR pin of the 82C55
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
15
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Resistor values in Fig 1121 are chosen so the segment current is 80 mA.
required to produce average 10 mA current per segment as the displays are multiplexed
A six-digit display uses a segment current of 60 mA for an average of 10 mA per segment. Peak anode current in an eight-digit display is 560 mA (seven segments 80 mA).
average anode current is 80 mA
16
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
In this display, the segment load resistor passes 80 mA current and has approximately 3.0 V across it. The value of the resistor is 3.0 V 180 mA = 37.5 Ohm. The closest standard resistor value of 39 Ohm is used in Fig1121. Programming the 82C55 is accomplished by the short sequence of instructions listed in Example 119. Ports A and B are programmed as outputs.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
17
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
18
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
19
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The data connections, which are attached to the 82C55 port A, are used to input display data and to read information from the display. For a 4-bit interface, D4D7 pins are used where the data must be formatted with the high nibble first, followed by the low nibble. A few newer OLED devices contain a serial interface that uses a single pin for the data.
20
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
To program DMC-20481 it must first be initialized. This applies to any display using the HD44780 (Hitachi) display driver IC. The entire line of small display panels from Optrex and most other manufacturers is programmed in the same manner. To program DMC-20481 it must first be initialized.
this applies to any display using the HD44780 (Hitachi) display driver integrated circuit
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
21
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
22
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
7. Output a 01H to home the cursor and clear the display, and wait at least 1.64 ms 8. Output the enable display cursor off (0CH), and wait at least 40 s 9. Output 06H to select auto-increment, shift the cursor, and wait at least 40 s
Software to accomplish the initialization of the LCD display is listed in Example 1112. The time delays can also be obtained by using a timer in C++.
23
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
After initialization, time delays are no longer needed when sending data or many commands to the display. The clear display command still needs a time delay as the busy flag is not used . Instead of a time delay, the busy flag is tested to see whether the display has completed an operation. The BUSY procedure tests the LCD display and only returns when the display has completed a prior instruction.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
24
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Once the BUSY procedure is available, data can be sent to the display by writing another procedure called WRITE. The WRITE procedure uses BUSY to test before trying to write new data to the display. Example 1114 shows the WRITE procedure, which transfers the ASCII character from the BL register to the current cursor position of the display.
25
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The only other procedure needed for a basic display is the clear & home cursor procedure, called CLS, shown in Example 1115. This procedure uses the SEND macro from the initialization software to send the clear command to the display. With CLS and the procedures presented thus far, you can display any message on the display, clear it, display another message, and basically operate the display.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
26
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
An inexpensive stepper motor is geared to move perhaps 15 per step A more costly, high-precision stepper motor can be geared to 1 per step.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
27
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
In all cases, these steps are gained through many magnetic poles and/or gearing. Figure 1123 shows a four-coil stepper motor that uses an armature with a single pole.
two coils are energized
If less power is required, one coil may be energized at a time, causing the motor to step at 45, 135, 225, and 315. The motor is shown with the armature rotated to four discrete places, called full stepping.
accomplished by energizing the coils, as shown
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
28
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1123 The stepper motor showing full-step operation: (a) 45 (b) 135 (c) 225 (d) 315.
29
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The motor is driven by NPN Darlington amp pairs to provide a large current to each coil. A circuit that can drive this stepper motor is illustrated in Fig 1124.
with the four coils shown in place
This circuit uses the 82C55 to provide drive signals used to rotate the motor armature in either the right- or left-hand direction. A simple procedure that drives the motor is listed in Example 1116 in both assembly language and as a function in C++.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
30
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1124 A stepper motor interfaced to the 82C55. This illustration does not show the decoder.
31
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The keys are organized into four rows and columns: (ROW0ROW3) (COL0COL3)
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
32
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1125 A 4 4 keyboard matrix connected to an 8088 microprocessor through the 82C55 PIA.
the 82C55 is decoded at I/O ports 50H53H for an 8088 port A is programmed as an input port to read the rows port B is programmed as an output port to select a column a flowchart of the software required to read a key from the keyboard matrix and debounce the key is illustrated in Fig 1126
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
33
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
keys must be debounced, normally with a time delay of 1020 ms the software uses a procedure called SCAN to scan the keys and another called DELAY10 to waste 10 ms of time for debouncing the main keyboard procedure is called KEY and appears in Example 1117 the KEY procedure is generic, and can handle any configuration from a 1 1 matrix to an 8 8 matrix.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
34
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The ShortDelay procedure is needed as the 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
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
35
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Port C is used in mode 1 operationnot for data, but for control or handshaking signals.
to help operate either or both port A and B as strobed input ports
Fig 1127 shows how both ports are structured for mode 1 strobed input operation.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
36
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1127 Strobed input operation (mode 1) of the 82C55. (a) Internal structure and (b) timing diagram.
37
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
STB
The strobe input loads data to the port latch, which holds the information until it is input to the microprocessor via the IN instruction.
IBF
Input buffer full is an output indicating that the input latch contains information.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
38
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
INTR
Interrupt request is an output that requests an interrupt. The INTR pin becomes a logic 1 when STB returns to a logic 1. Cleared when data are input from the port by the processor.
INTE
Interrupt enable signal is neither input nor output; it is an internal bit programmed via port PC4 (port A) or PC2 (port B) bit position.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
39
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
PC7, PC6
The port C pins 7 and 6 are general-purpose I/O pins that are available for any purpose.
40
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
41
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1128 Using the 82C55 for strobed input operation of a keyboard.
42
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
When data are written to a strobed output port, the output buffer full signal becomes logic 0 to indicate data are present in the port latch.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
43
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1129 Strobed output operation (mode 1) of the 82C55. (a) Internal structure and (b) timing diagram.
44
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
OBF
Output buffer full goes low whenever data are output (OUT) to the port A or B latch. The signal is set to logic 1 when the ACK pulse returns from the external device.
45
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
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.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
46
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
INTE
Interrupt enable is neither input nor output; it is an internal bit programmed to enable or disable the INTR pin. INTE A is programmed using PC6 bit. INTE B is programmed using the PC2 bit.
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.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
47
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
48
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1130 The 82C55 connected to a parallel printer interface that illustrates the strobed output mode of operation for the 82C55.
49
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Also used for IEEE-488 parallel high-speed GPIB (general- purpose instrumentation bus) interface standard. Figure 1131 shows internal structure and timing for mode 2 bidirectional operation.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
50
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1131 Mode 2 operation of the 82C55. (a) Internal structure and (b) timing diagram.
51
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
OBF
Output buffer full is an output indicating the output buffer contains data for the bidirectional bus.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
52
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
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.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
53
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
54
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
IBF
Input buffer full is an output used to signal that the input buffer contains data for the external bidirectional bus.
INTE
Interrupt enable are internal bits (INTE1 & INTE2) that enable the INTR pin. The state of the INTR pin is controlled through port C bits PC6 (INTE1) and PC4 (INTE2).
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
55
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The external circuitry also monitors the signal to decide whether the microprocessor has sent data to the bus.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
56
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
To receive data through the bidirectional port A bus, IBF is tested with software to decide whether data have been strobed into the port.
if IBF = 1, data is input using IN
The external interface sends data to the port by using the STB signal.
the IBF signal becomes logic 1 and data at port A are held inside the port in a latch
When the IN executes, the IBF bit is cleared and data in the port are moved into AL. See Example 1121 for a procedure.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
57
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The INTR (interrupt request) pin can be activated from both directions of data flow through the bus. If INTR is enabled by both INTE bits, the output and input buffers both cause interrupt requests. This occurs when data are strobed into the buffer using STB or when data are written using OUT.
58
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
59
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1132 A summary of the port connections for the 82C55 PIA.
60
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
61
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
this memory interface has two signal lines one is a serial clock (SCL); the other a bidirectional serial data line (SDA) not meant to replace system main memory it is fast enough for music or other low-speed data
62
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Refer to Figure 1024. The data format for the software for reading and writing data to the EEPROM is also illustrated in Example 1122. This software is written in C with some assembly language, but it can also be developed in assembly language. I/O port address for the command register is 0x1203, and 0x1202 for the port C register.
the time delay should be 1.25 s for a data rate of 400 KHz
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
63
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Chapter 10, Figure 1024 Data signals to the serial EEPROM for a read or a write.
the serial data contains the address in the first byte as well as a device code of 1010, which represents the EEPROM other serial devices have different device codes this is followed by the memory location and the data in additional bytes
64
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
65
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Usage includes real-time clocks, event counters, and motor speed/direction control. Timer appears in the PC decoded at ports 40H43H to do the following:
1. Generate a basic timer interrupt that occurs at approximately 18.2 Hz 2. Cause the DRAM memory system to be refreshed 3. Provide a timing source to the internal speaker and other devices.
66
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
67
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1133 The 8254 programmable interval timer. (a) Internal structure and (b) pin-out. (Courtesy of Intel Corporation.)
68
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The signals that connect to the processor are the data bus pins (D7D0), RD, WR, CS, and address inputs A1 and A0. Address inputs are present to select any of the four internal registers.
used for programming, reading, or writing to a counter
69
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Timer zero generates an 18.2 Hz signal that interrupts the microprocessor at interrupt vector 8 for a clock tick.
often used to time programs and events in DOS
Timer 1 is programmed for 15 s, used on the PC to request a DMA action used to refresh the dynamic RAM. Timer 2 is programmed to generate a tone on the PC speaker.
70
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
CLK
The clock input is the timing source for each of the internal counters. This input is often connected to the PCLK signal from the microprocessor system bus controller.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
71
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
CS
Chip select enables 8254 for programming and reading or writing a counter.
G
The gate input controls the operation of the counter in some modes of operation
GND
Ground connects to the system ground bus.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
72
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
OUT
A counter output is where the waveform generated by the timer is available.
RD
Read causes data to be read from the 8254 and often connects to the IORC signal.
Vcc
Power connects to the +5.0 V power supply.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
73
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
WR
Write causes data to be written to the 8254 and often connects to write strobe IOWC.
74
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The control word allows the programmer to select the counter, mode of operation, and type of operation (read/write).
also selects either a binary or BCD count
75
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
76
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Each counter may be programmed with a count of 1 to FFFFH; A count of 0 is equal to FFFFH+l (65,536) or 10,000 in BCD. Timer 0 is used in the PC with a divide-by count of 64K (FFFFH) to generate the 18.2 Hz (18.196 Hz) interrupt clock tick.
timer 0 has a clock input frequency of 4.77 MHz + 4 or 1.1925 MHz
The order of programming is important for each counter, but programming of different counters may be interleaved for better control.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
77
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Modes of Operation
six modes (05) of available to each of the 8254 counters each mode functions with the CLK input, the gate (G) control signal, and OUT signal
Figure 1135 The six modes of operation for the 8254-2 programmable interval timer. The G input stops the count when 0 in modes 2, 3, and 4.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
78
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
79
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 0
Allows 8254 to be used as an events counter. Output becomes logic 0 when the control word is written and remains until N plus the number of programmed counts. Note that gate (G) input must be logic 1 to allow the counter to count. If G becomes logic 0 in the middle of the count, the counter will stop until G again becomes logic 1.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
80
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 1
Causes function as a retriggerable, monostable multivibrator (one-shot). G input triggers the counter so it develops a pulse at the OUT connection that becomes logic 0 for the duration of the count.
if the count is 10, the OUT connection goes low for 10 clocking periods when triggered
If G input occurs within the output pulse, the counter is reloaded and the OUT connection continues for the total length of the count.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
81
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 2
Allows the counter to generate a series of continuous pulses one clock pulse wide.
pulse separation is determined by the count
For a count of 10, output is logic 1 for nine clock periods and low for one clock period. The cycle is repeated until the counter is programmed with a new count or until the G pin is placed at logic 0.
G input must be logic 1 for this mode to generate a continuous series of pulses
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
82
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 3
Generates a continuous square wave at the OUT connection, provided the G pin is logic 1. If the count is even, output is high for one half of the count and low for one half of the count. If the count is odd, output is high for one clocking period longer than it is low.
if the counter is programmed for a count of 5, the output is high for three clocks and low for two clocks
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
83
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 4
Allows a single pulse at the output. If count is programmed as 10, output is high for 10 clocking periods and low for one period.
the cycle does not begin until the counter is loaded with its complete count
Operates as a software triggered one-shot. As with modes 2 and 3, this mode also uses the G input to enable the counter.
G input must be logic 1 for the counter to operate for these three modes
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
84
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Mode 5
A hardware triggered one-shot that functions as mode 4.
except it is started by a trigger pulse on the G pin instead of by software
85
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
86
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1136 The 8254 interfaced to an 8 MHz 8086 so that it generates a 100 KHz square wave at OUT0 and a 200 KHz continuous pulse at OUT1.
87
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The PLD also generates a wait signal for the microprocessor that causes two wait states when the 8254 is accessed. The wait state generator connected to the microprocessor actually controls the number of wait states inserted into the timing. Example 1124 lists the program that generates a 100 KHz square-wave at OUT0 and a 200 KHz continuous pulse at OUT1.
88
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Reading a Counter
Each counter has an internal latch read with the read counter port operation.
the latches will normally follow the count
If counter contents are needed, the latch can remember the count by programming the counter latch control word. See Figure 1137.
counter contents are held in a latch until read
89
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
90
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
When a read from the latch or counter is programmed, the latch tracks the contents. When necessary for contents of more than one counter to be read at the same time, the read-back control word is used Illustrated in Figure 1138.
91
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
92
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
With the read-back control word, the CNT bit is logic 0 to cause the counters selected by CNT0, CNT1, and CNT2 to be latched. If the status register is to be latched, then the bit is placed at logic 0. Figure 1139 shows the status register, which shows:
the state of the output pin whether the counter is at its null state (0) how the counter is programmed
93
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
94
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
95
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1140 Motor speed and direction control using the 8254 timer.
if Q output of the 74ALS112 is logic 1, the motor spins in its forward direction if logic 0, the motor spins in reverse if flip-flop output alternates between logic 1 and 0, the motor spins in either direction at various speeds if the duty cycle of the Q output is 50%, the motor will not spin at all and exhibits some holding torque
96
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Fig 1141 shows some timing diagrams and effects on the speed/direction of the motor. Each counter generates pulses at different positions to vary the duty cycle at the Q output of the flip-flop. This output is also called pulse width modulation. Example 1125 lists a procedure that controls the speed and direction of the motor.
97
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1141 Timing for the motor speed and direction control circuit (a) No rotation, (b) high-speed rotation in the reverse, and (c) high-speed rotation, forward direction.
98
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
99
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
An 8-bit converter that transforms an 8-bit binary number into an analog voltage. Other converters are available that convert from 10-, 12-, or 16-bit binary numbers into analog voltages.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
100
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The number of voltage steps generated by the converter is equal to the number of binary input combinations.
an 8-bit converter generates 256 voltage levels a 10-bit converter generates 1024 levels
The DAC0830 is a medium-speed converter that transforms a digital input to an analog output in approximately 1.0 s.
101
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1148 shows pin-outs of a DAC0830. The device has eight data bus connections for the application of the digital input code. Analog outputs labeled IOUT1 & IOUT2 are inputs to an external operational amplifier. Because this is an 8-bit converter, its output step voltage is defined as VREF (reference voltage), divided by 255.
the step voltage is often called the resolution of the converter
102
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
103
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The two latches allow one byte to be held while another is converted. The first latch is often disabled and the second for entering data into the converter.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
104
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
105
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The output of the R2R ladder within the converter appears at IOUT1 and IOUT2. These outputs are designed to be applied to an operational amplifier such as a 741 or similar device.
106
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
The 741 operational amplifier, along with the 12 V zener reference voltage, causes the fullscale output voltage to equal +12 V. See Fig 1150.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
107
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1150 A DAC0830 interfaced to the 8086 microprocessor at 8-bit I/O location 20H.
108
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
ADC080X requires up to 100 s to convert an analog input voltage into a digital output code. Figure 1151 shows the pin-out of the ADC0804 converter.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
109
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
110
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
To operate the converter, the WR pin is pulsed with CS grounded to start the conversion process. See Fig 1152 for a timing diagram that shows the interaction of the control signals. If a time delay is used that allows at least 100 s of time, there is no need to test INTR pin. Another option is to connect the INTR pin to an interrupt input, so when the conversion is complete, an interrupt occurs.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
111
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1152 The timing diagram for the ADC0804 analog-to-digital converter.
112
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
These differential inputs are summed by the operational amplifier to produce a signal for the internal analog-to-digital converter. These inputs are connected to an internal operational amplifier as shown in Fig 1153.
113
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1153 The analog inputs to the ADC0804 converter. (a) To sense a 0- to +5.0 V input. (b) To sense an input offset from ground.
114
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
If generated with an RC circuit, CLK IN and CLK R pins are connected to an RC circuit, as illustrated in Figure 1154.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
115
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1154 Connecting the RC circuit to the CLK IN and CLK R pins on the ADC0804.
116
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Suppose ADC0804 is decoded at I/O port address 40H for the data and address 42H for INTR. The procedure to read data is listed in Example 1129.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
117
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
118
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
For human quality speech, we can use an ADC0804 to capture an audio signal and store it for later playback through a DAC0830.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions
119
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Fig 1156 shows circuitry required to connect the ADC0804 at I/O ports 0700H and 0702H. The DAC0830 is interfaced at I/O port 704H.
These ports are in the low bank of a 16-bit microprocessor such as the 8086/80386SX
The software appears in Example 1130. It reads a 1-second burst of speech and plays it back 10 times.
120
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
Figure 1156 A circuit that stores speech and plays it back through the speaker.
121
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
A procedure called READS reads the speech. A second, PLAYS, plays it back. The speech is sampled and stored in a section of memory called WORDS. The sample rate is chosen at 2048 samples per second, which renders acceptablesounding speech.
122
Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.