Zaks - Microprocessor - Interfacing - Techniques
Zaks - Microprocessor - Interfacing - Techniques
LESEA
s:-
()
JJ
0
-a
JJ
--tO
mo
om
::r: (/)
zcn
-0
OJJ
C-
mZ
(/) --f
m
JJ
~
()
-z
( G)
029-6
MICROPROCESSOR
INTERFACING -.
TECHNIQUES
. _._
.. -~
r
MICROPROCESSOR
INTERFACING
TECHNIQUES
RODNAYZAKS
AUSTIN LESEA
THIRD EDITION
Every effort has been made to supply complete and accurate information. However, SYBEX
assumes no responsibility for its use, nor for any infringements of patents or other rights of third
parties which would result.
20 19 18 17 16 15 14 13 12
ACKNOWLEDGEMENTS
The following persons or companies have supplied valuable information, photo-
graphs, programs or schematics of their products or projects: Although not all in-
formation supplied could be used, their cooperation is gratefully acknowledged.
Intel, Motorola, Persci (disks), Shugart (disks), Thomson-CSF (CRTC board), David
Reinagel (Music Synthesis), Rockwell, Data 1/0 (programmer), Prolog (programmer),
Zilog, Hewlett-Packard (analyzers), Control Data (disks), North Star, lmsai, Altair
(SIOO bus), Tarbell (cassette interface), Component Sales (keyboards), MOS Tech-
nology, Advanced Micro Devices, Fairchild, NEC, Western Digital, Dynabyte (RAM),
National Semiconductor, Analog Devices, Lawrence Laboratory, University of
California at Berkeley, Power-One (power supply), Fluke, Biomation (analyzer),
Trendar (fault analysis)
ALSO AVAILABLE IN:
-FRENCH
-GERMAN
-DUTCH
-SWEDISH
-JAPANESE
-ITALIAN
(more to be published)
TABLE OF CONTENTS
Computer interfacing has traditionally been an art, the art to design and
implement the required control electronics for connecting a variety of
peripherals to the main processor.
With the advent of microprocessors, and of LSI chips. since 1976, mi-
croprocessor interfacing is no longer an art. It is a set of techniques. and in
some cases just a set of components. This book presents the techniques and
components required to assemble a complete system, from a basic central
processing unit, to a system equipped with all usual peripherals, from
keyboard to floppy-disk.
Chapters two and three are recommended reading for every designer .
who has not had the experience of designing a basic system. Chapter two
presents the construction of a basic CPU, in the case of popular micro-
processors such as the Intel 8080, 8085, and the Motorola 6800. Chapter
three presents the set of input-output techniques used to communicate with
the external world, and a brief survey of the existing chips which facilitate
the implementation of these techniques.
Chapter four is an essential chapter: the microprocessor-based CPU will
be successively interfaced to every major peripheral: keyboard. LED. tele-
type, floppy-disk, CRT display , tape-cassette.
The following chapters then focus on specific interfacing problems and
techniques, from industrial design (analog-to~digital conversion) (chapter
five) to communication with the outside world (busing. including S-100 and
other bus standards), in chapter six.
Chapter seven presents a detailed case study, which incorporates the
interfacing principles presented in the previous chapters: the design of a
real 32-channel multiplexer.
Finally, chapter eight presents the basic techniques and tools for
trouble-shooting microprocessor systems.
This book assumes a basic understanding of microprocessor systems'.
equivalent to the level of book C201 - Microprocessors: from chips to sys-
tems.
1
INTRODUCTION
OBJECTIVE
IS
MICROPROCESSOR INTERFACING TECHNIQUES
16
INTRODUCTION
the MOS LSI process, it is not yet possible to integrate the complete
memory, plus 1/0 facilities, directly on the microprocessor chip. In
the standard system, the microprocessor itself (abbreviated MPU),
and perhaps the clock, reside on a single chip. The memory (ROM,
Read-Only Memory, and RAM, or Random-Access Memory) is exter-
nal. Because memory and 1/0 chips are external to the
microprocessor, a selection mechanism must be provided for addres-
sing the components: a microprocessor must be equipped with an ad-
dress bus. The standard width of the address bus in 16 bits, permitting
the addressing of 64 K locations (where K = 1,024: 2 16 = 64K).
An 8-bit microprocessor will transfer 8-bit data. It must be
equipped with an 8-bit data bus. This requires 8 additional pins.
At least two pins must be provided for power, and two more for
connection to an external crystal or oscillator. Finally, l Oto 12 control
lines must be provided for the coordination of data transfers in the
system (the control bus). The total number of pins used is 40. No pins
are left unused.
Because of this pin-number limitation, a 16-bit microprocessor can-
not provide a 16-bit address bus and a 16-bit data bus at the same
time. One of the buses must be multiplexed. This results in turn in a
slower operation, and in the necessity of external components to
multiplex and de-multiplex the buses.
It can be expected that the progress of integration will soon introduce
a new standard microprocessor, the 16-bit microcomputer-on-a-chip.
A microcomputer-on-a-chip is a microprocessor-plus-clock-plus-
memory (ROM + RAM) on a single chip. Since the memory is direct-
ly on the chip, there is no longer the necessity of providing an ex~ernal
address bus. 16 pins become available. In such a system, at least 24
lines become available for data transfers. They are general-purpose
1/0 lines. The disadvantage of current microcomputers is that , for the
time being, the quantity of memory which may be implemented direct-
ly on the microcomputer chip is limited. The current limitation is 1048
words for the ROM, and 512 words for the RAM . Adding external
memory involves complex multiplexing and demultiplexing, and is
usually not worth it. However, if a system can be implemented in the
near future with a significantly larger memory, it can be expected thal
it will become the next standard design.
For the time being, the 8-bit microprocessor is indeed the standard
design used for "powerful" and flexible applications, and will be
referred as such . The basic diagram showing the architecrure of a stan-
dard system appears in Fig. 1-1. The microprocessor itself, labeled
17
MICROPROCESSOR INTERFACING TECHNIQUES
POWER
1/0 llVS
r----,
I l/0 I
MPU
XTAL 1/0 BUS
I
I '
I
r !IV!CESr
I I
CONTROL - - - .I
CLOCK
16-BIT ADDRESS BUS
CONTROL LINES
18
INTRODUCTION
19
N
C ~
6502 I ()
,0
0
"
,0
0
+-ALE I I I ()
m
u,
-··--------- u,
HOLD HOLD BUSRQ HALT RDY
CLK
0
fJ2 - ·- fJl stretched fJ2 stretch ,0
~ INT INTR INT IRQ IRQ
IJC.
. INTE -- -- -- -- z
-I
..-
WAIT -- -- -- -- m
,0
N
I READY READY WAIT -- ROY "Tl
RESET RESET RESET RESET RESET )>
()
r,; SYNC -- Ml -- SYNC
mi'· INTA INTA Ml&IORQ VMA&FFF8 -- z
=
!.
MEMR
MEMW
RD&IO/M
WR&l0/M
RD&MEMRQ
WR&MEMRQ
R/W&fJl.
as above
RfW&fJl
as above
(j)
-I
m
~ I/O RD RD&lO/M- RD&IORQ as above as above ()
~ 1/OWR WR&IO/M- WR&IORQ :I:
as above as above
5.
-41!
BUSEN -- -- HALT -- z
~ SSTB -- -- -- -- D
~ OTHER -- R~T S.S -- -- -- C
=
~
~
flJ
CONTROL
SIGNALS
--
--
RST6.S
RST 7.5
--
--
- - --
m
u,
sented in the next chapter. The third bus is the only complex one.
It carries the microprocessor control signals or "interface
signals."
The control bus provides four functions:
l . memory synchronization
2. input-output synchronization
3. MPU scheduling - interrupt and OMA
4. utilities, such as clock and reset.
21
MICROPROCESSOR INTERFACING TECHNIQUES
L>BIN
'11,R
SYNC.
8080
8224
READY MPU
INTA
RESET DO
WO
WAIT ST
CLOCK
o, I/OR
02
INT Ml
INTE MEMR
HOLD
,, ,, .. ,, ,.
"
n '\__._ n n n n
L.rL LI1~- u------L Lr7._ u------L'---17.-
.... I l ta.allliiUWflf
\
X
- JI 11 ...ll
l-
-----•---
_
..••Hlll(Klt
tLOAtlti,G
..__.,.....
t1.0•1•trK.
I
I \
I DU"
\
\
•'"'"'
....,01u11•tNN11
....
•.....
•fllOll'l' .....f.U
.,._,,,.,_,
MK.V&-.toAlt
_,~,
..-·....... ...._,,,o..,,.
flt~N0,AI..
--•l
....,,.,.,...........,'°"
..ODI..CI~•
••lfOII•
-St""Utt.0,,0
::.':~:
...
If IHOYMIIO
...~- .,
A.CCI . . , _
~
11&(11
22
INTRODUCTION
r,
DB•N IS TRIGGERED BY 0
2
DBE
~.. 00-07
TSC
HALT -
-
6800 NM! --
RESET
nm
BA
VMA
R/W
~l -
A0-Al5 CLOCK
a2 -
~
.. 15
v~ ....
I A1mReSS RIIS )
'''
¥
.,
23
MICROPROCESSOR INTERFACING TECHNIQUES
§1
CLOCK
/2
RESET
IRQ
INTERRUPTS
NM! -
HALT -
3-STATE CONTROL
DATA BUS ENABLE -
BUS AVAILABLE ~
R/W -
i
I
VALID MEMORY ADDRESS i
24
... , ., ·
,.,
,!;:·-1rr\,\\W(\fv\(\r_ '.', .
25
2
ASSEMBLING THE CENTRAL
PROCESSING UNIT
INTRODUCTION
26
ASSEMBLING THE CENTRAL PROCESSOR
illustrates the trade-off between yield and die-size. Yields also increase
with manufacturing experience-this is called the "learning-curve";
costs decrease with higher quantities, because of improved yield.
1,000,000?
NUMBER
10,000
OF
TRANSISTORS/
CHIP
1,000
YEAR
YIELD l
DIE SIZE
27
MICROPROCESSOR INTERFACING TECHNIQUES
SYSTEM ARCHITECTURE
28
ASSEMBLING THE CENTRAL PROCESSOR
cH ~, 1
1 ..
1r ~_1rl I{ DATA
t;D11 ~fM1 ~~1
11 II~~ ADDRESS
fr 1111 11 II {>I I
JI {> 111 I ~> {> I[
1/ 0
Linear Selection
29,
MICROPROCESSOR INTERFACING TECHNIQUES
one of the 256 possible locations in each chip. Besides these eight lines,
the processor must be able to select one device at a time. RAM and
ROM devices have, in addition to their address inputs, at least one
"chip-select" (CS). This select line, when activated, allows the opera-
tion to be per-formed on the device (Read or Write).
Two basic techniques are used to implement the chip selection.
Linear-selection connects individual address lines to individual chip-
select inputs. For example, if the most-significant address bit (bit 15) is
tied to a chip-select, that chip is selected whenever the most-significant-
bit is a one. This occurs for half of the total memory locations. Assume
that our ROM is selected by this most-significant-bit being "0" and the
RAM by this bit being "1." To address the 256 locations available in-
side each device, we will connect lines AO to A 7 of the address bus.
The essential advantage of linear-selection is simplicity: no special
logic is necessary in order to select chips. Each new chip is selected b·y
a dedicated address line. This is, indeed, the approach used in all small
microprocessor systems.
For example, a 1K x 8 ROM chip will be used and a 512 x 8 RAM,
plus 3 peripheral chips. The IK ROM requires 10 lines for address
selection: AO - A9, plus one line for the chip-select: Al4. The RAM
will use AO - A8 for address selection, and Al5 for the chip-select.
Lines Al0, All, Al2, Al3 may be used for additional devices.
l
ROM
cs
RAM PIO
cs cs
30
ASSEMBLING THE CENTRAL PROCESSOR
Fully-Decoded Addressing
A 15
A 14
A 13
A 12
A 11
A 10
A9
AS
AO --A7
Instead of using AND gates for every device, there exist general-
purpose gating devices known as decoders. An example is the 8205 or
74LS138 three-to-eight decoder. The 8205 has three inputs to select
one of eight mutually exclusive outputs, in function of three enable in-
puts. When the three enable inputs are in their proper states, one of
the outputs will be active, depending on the three select lines. Ex-
amples using the 8205 will be presented in the hardware section to
clarify full-decoding schemes.
31
MICROPROCESSOR INTERFACING TECHNIQUES
AO
-- so
Al S1
A2 - S2
-
: S4
S3
:. S5
1:1
E2
-
: ..-- S6
E3 - ...
~
S7
Storage Chips
The basic devices for storing information now used are the RAM
and the ROM. The ROM contains permanent information and cannot
be changed by the system. The RAM allows for temporary storage and
retrieval of information. The program information is usually kept in a
non-volatile ROM since it does not change, and the data and interme-
diate results are stored in RAM.
"RAM" usually refers to a semiconductor device, but is also used
for other storage media, such as core memory.
A RAM chip may contain from 256 to 16,384 cells, each cell repre-
senting a bit of the information word or byte. Each cell may consist of
a flip-flop type structure-in which case it is a static device, or it may
consist of a capacitor structure-in which case it is a dynamic device.
The static RAM will retain information as long as power is present,
32
ASSEMBLING THE CENTRAL PROCESSOR
A(J
GAS
A7
ROM will refer here to an LSI device, but may also be used to
denote other types of read-only memories. Several types of ROMs are
available. The masked ROM is "programmed" by the manufacturer
and will stay programmed for the life of the chip. It cannot be altered.
The PROM is programmed by the user and may either be of the
fusible-link type, where a bit is programmed by blowing a microscopic
fuse, or it may be a stored-charge type that will retain the pattern for
tens of years. The latter type is also known as an EPROM because it
can be erased by ultraviolet light and reused. The EAROM is elec-
trically erasable and could be considered as RAM except that it takes
100 milliseconds or longer (typically) to erase the device. This makes it
inconvenient to use as a scratchpad for calculations or data manipula-
tions. The use of EAROMs has been restricted so far to military appli-
cations.
33
MICROPROCESSOR INTERFACING TECHNIQUES
Each input of a device presents a load on the output driving it. Most
components drive anywhere from one to twenty other components.
Every component must be checked for its input and output loading ·
and driving characteristics.
The microprocessor's buses must connect toeverymemory and peri-
pheral input-output chip in a system. All MOS microprocessors lack
the output drive needed for a large system. Because of this, buffers or
drivers are used to boost the driving power of the buses. There are bus
transmitters for driving the bus, and bus receivers for listening to the
bus and driving the processor.
· CONTROL
LOGIC
Fig. 2-8 illustrates the use of transmitters to buffer the address and
control buses. The lines on the address and control buses are unidirec-
tional: the data flows in one direction.
Fig. 2-9 illustrates the use of bus transceivers for the data bus. Data
must pass in both directions, so both transmitters and receivers are
used. The bidirectional data bus will receive data and transmit data,
depending on the function being performed.
34
ASSEMBLING THE CENTRAL PROCESSOR
MEMORY
MPU
Intel's 8080 has been the most widely used "standard" -architecture
microprocessor. The 8080 is a popular processor also used in many
hobby microcomputers. We will assemble the complete central pro-
cessing module for a typical 8080 computer system. The connection of
the clock, system controller, RAM, and ROM will be presented. The
input-output will be covered in detail in Chapter 3.
The Clock
35
MICROPROCESSOR INTERFACING TECHNIQUES
..
25
..
....
77
29
JO
..,.
31
33
..
INJ 14 _
- 8080A 34
35
- INTE 16
l
4()
37
...
38
39 .
rl □ 1
36 Al
13
"°'°
HlOA 21
·t ,!
17
06IN
14
I •-
Wfl
18
,. 3"
OCSOUT
. l '9 SYNC
23
10
••
17 ,.
13
.•
00
..
...
ROY IN "ll
12 11
RfAOY
7 10
~ 822<1
1
" RfSET
3
•s •
19 8228 18
21 20
01 02
• • 7
D7
02(ffil
SIS!B
11
10
,_ 7
..t
··j
-
-·.. ..
MOM
1100!
t/OW
,...,
....
25
11
.,.,
t
RUSEN
• 22
---
---
INT
"'ffl
IIOY
TANK
0 2 TTL
02
SYNC
STB
RST
RESET
RIN READY
FF
36
ASSEMBLING THE CENTRAL PROCESSOR
When designing the 8080, the lack of pins became a major limita-
tion. In order to gate out the required control signals, pins have to be
multiplexed. Control or address functions would have to share lines
with the data bus. In this case, the designers chose to multiplex control
information or status on the data bus. This status byte may be latched
for use at the time of the SYNC signal. The lack of pins is essentially
due to the early technology used for the 8080, which required three
power levels using four pins.
Early processor designs used latches and random logic to capture
these status signals. In fact, this is why the actual SlOO bus still retains
what is known as the old 8080 status signals. The design of what
became known as the system controller appears in Fig. 2-12. The latch
holds the status information, and the gates decode the status along
with the other 8080 control lines into control signals for the memory
and input-output devices.
BUSEN
D0
2, 4 r 3
DB0
Dl
5, 7
r 8216 6 081
D2
9,ll r 10
082
D3
12,14 r DIEN cs
l3 DB)
l~ 9 Y1
D4 2. 4 r 1 0B4
D5 5, 7 r 8216 6 085
D6 o ll r 0
086
D7
12 ,14 r DIEN cs
13 D87
Y1
OBIN
<{>-{) 1£r
3 4 INTA
-
--....--
8080 Li:
1
~;:;;;
8 STACK
J
9 10 HLTA
16
18
8212
.. -
l ' OUT
10 TNP r--L.)>-
..... .
"' .,, ·-·-
ffiTi
22
1
~ Vcc r
.~
~
T -
iiR
37
MICROPROCESSOR INTERFACING TECHNIQUES
Di!
I
DBi!
CPU
DATA
BUS
I Dl
02
D3
D4
D5
B1-0 I llECTIONAL
BUS DRIVrn
DBl
0B2
0B3
DB4
D85
SYSTEN
DATA
BUS
D6 DB6
07 DB7
o - - MHIR
STATUS
v - - - ME~W
LATCH GATl:IG P-- I/OR
ARRAY v - - - I/OW
smi _ _ _ _ _ ____. BllSEN
o - - - liJTA
-------------...f
OBIN
WR ------------<1
HLOA - - - - : - - - - - - - - ~
The trio of 8224, 8228, and 8080 now completes the central pro-
cessor function. The only other component required is the crystal. To
complete the CPU we need to add the program memory and the
random-access memory (ROM and RAM).
38
ASSEMBLING THE CENTRAL PROCESSOR
Addrenbitl Al>
Al)-A9 A9
2708
EPROM
8205 cs (lK X 8 )
Al AO
All Al
Dfl· · · 0 7
A l2 A2
A1 3
Al4
A15
,- - - - - - - - - - - -
1 I
cs 2708
DECODING :.....1'.- - - - -- - - - - -/
DELAY
L_ PROM ---l
r--- ACCESS
TIME
39
MICROPROCESSOR INTERFACING TECHNIQUES
DATA IN
' " - - - - - - ADDRESS
DATA OUT ..---4----1 I BIT
X
N
RAM
IN/OUT
QUAD TRANSCEIVER
DO
40
ASSEMBLING THE CENTRAL PROCESSOR
256 by 4 implies that two devices are needed to complete the byte.
The schematic for the 256 by 4 memories, interfaced to the 8080 bus,
appears in Fig. 2-17.
DATA BUS
o0 DC b3 o4 c6D~ o7
~ ~
Al J
A J
..,
• 256 X 4 .i 256 X 4
AJ
t,F,
RAM .•
• RAM
Al 4,
cs J-
cs
'--
r MB>\ W
M81 R
The address bus lines needed to specify the address are connected to
each RAM chip. The eight address lines will select one of the 256 bytes
in each RAM chip. The unused eight address lines are decoded by an
eight-input NANO gate. As per our earlier discussion, the RAM will
be located from FFOO to FFFF hexadecimal. The data bus splits in
two, with four bits going to each of the 256 x 4 bit RAMs. Actual
data bus connections are shown in Fig. 2-16. Control lines are needed
to enable the memories for reading and writing as well as to control
the timing of the writing operation. The 2111 RAMs used here have a
number of extra enable inputs, as well as read/write lines. The two
signals "memory-read" and "memory-write," are used to control the
RAMs. "Memory-read" enables the output drivers of the chips to
drive the data bus. At all other times, the ·chip is in a read mode, but
will not place information on the bus. "Memory-write" enables the
RAM to perform a write cycle and gates data presented on the data
bus into the RAMs. Timings of these operations are illustrated in Fig.
2-18.
41
MICROPROCESSOR INTERFACING TECHNIQUES
AIJIJlESS
x x
MEM R
READ CYCLE
CHIP SELECT
I .ACCESS I
M8'1 W ---.... TIME
42
D0
D7
4 x 8708 = 4K
~
ac·
. '
-- ~------
N
I
---- ______
lK x 8 ,_~------
~------ lK x 8
---
~
"!? -------
______
~------
("') ~------
,... 8111 8111
0 8708 -- 8708 RAM
= - RAM
-
"Cl
-
~
~
,_ EPROM
---,·
---
-- EPROM -= 4 X 256 = 4 X 256 ~
-
1
QC
m
iQ MEMR - CS - CS ~
8205 D--8708 - D P/W CS - D RIW CS 0::,
r-
y I \ J I
00
,,, I - ~708 MEMR z
'--e -
-3
~ +5 - DECODER -- -
MEMW
(j)
-I
J:
m
--{::::: n
~ A0 m
z-I
3
0 ;;o
·'- )>
r-
-0
A9 ;;o
0
All =====t====::!:=t===+==========::=================================== n
m
e ====:::!::========:!:============================================== C/)
~
Al5 - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - - ;o
MICROPROCESSOR INTERFACING TECHNIQUES
DATA BUS
R/W
Tcvc
01
02
44
ASSEMBLING THE CENTRAL PROCESSOR
The Clock
6800 Buses
The 6800 architecture uses memory-mapped input-output (see
Chapter 3) and requires only a single power-level, versus three for the
8080. As a result, no multiplexing is required to gate the control sig-
nals. However, the buses need to be buffered in any large system.
making the parts count essentially equal to 8080 and 6800 systems.
(The 8228 system controller includes a data bus driver).
The data bus is a bidirectional 8-bit bus. It requires buffering for
most applications. The suggested Motorola components appear in
Fig. 2-22.
DATA
II: 6880
QUAD 3-STATE BUS EXTENDER
aus
IIC 8126
6800
XC 6885
A.ODRFS;~ HEX 3-STATE BUFFER INVERTER
811S
u
XC 8195 ltONllNVl~TIIIG AVAllAAll
45
MICROPROCESSOR INTERFACING TECHNIQUES
The ROM
An
An+l
An+2
- - - - An+3
r r 1 r
- --
CHIP 1 CHIP2 CHIP3 CHIP 16
46
ASSEMBLING THE CENTRAL PROCESSOR
In the example of Fig. 2-25, the chip selects are connected to three
of the high-order address bits, and to the VMA signal ANDed with the
f 2 signal. In this way, the ROM is selected for any valid memory ad-
dress cycle from lCOO to FFFF hexadecimal. Of course,the ROM is
only 1024 bytes, so the large area it takes up is due to the "don't
cares" or the undecoded address bits: Al5, Al4, and A13.
D0-D7
1 K BYTE
AO-A9 ROM
AlO
CSl
CS2 VMA•~.2
CS3 cso
+5V
ADDRESS BUS
CONTROL BU
The RAM
47
MICROPROCESSOR INTERFACING TECHNIQUES
this example, RAM is selected when A 11 through A 7 are all low. This
would be address 0000 through 00FF hexadecimal. Since the highest
four address bits are not fully decoded, the memory is also enabled for
addresses 1000 through lOFF. Similarly, it is enabled for 2000 through
20FF, and so on, ending with FOO0 through F0FF.
(
~
DATA BUS :)
"'
.. 00-D7
r
"
J
128 BYTE
.. RAM
,,,/
" A0-A6
A7
AS
- CSJ
VMA-~2
CS2 CS3
A9
CS4 RIW
.,. CS5
Al0 , -
cso ~
_L
I +5V
-;-
All .
l ...
I ADDRESS BUS
,,
...
~ .
CON 11<ul tsu::,
In order to use our RAM with our ROM, we must select those
places where the two do not overlap. One example is ROM from FCOO
through FFFF and RAM from 0000 through OOFF.
The VMA and (j 2 signals select the device for the memory cycle,
and "read/write" controls the function-fetching or storing.
48
RESTART
TSC RES
~
~·
~
~ ROM Al2
CS0 PORT
n
0 cs CSl P A
3
MPU )>
(/)
~ CS2 I PORT U>
m
;-
[ E A B s:
OJ
,-
R/W
Cl'\
QC - z
=
= A7 A8
G)
-i
00 ::c
-
~
':ll
t'D
3
CLOCK
01
02
VMA ADDRESS BUS
m
()
m
z-I
;;t:,
IRQ R/W )>
,-
VMA, 02 '1J
;;t:,
0
- - ()
m
(/)
(/)
,II,.
IC
0
;;t:,
MICROPROCESSOR INTERFACING TECHNIQUES
THE Z-80
CLOCK
[;:;]
+sv GND
ADDRESS
MREQ IN
+sv RO
ROM
DATA
Z-8U
s
DATA
RESET OUT
IORQ
T PIO
Ml
...
OUTPUT INPUT
DATA DATA
50
ASSEMBLING THE CENTRAL PROCESSOR
order to renew, or "refresh" the cell. The Z-80 provides the refresh
address using a design trick.
After an instruction is fetched, the address bus no longer needs to
remain stable. Instead of wasting this time, the Z-80 outputs a fresh
address on the lower 7 address bits. This address increments once each
instruction cycle, and with the additional internal refresh register, dy-
namic memories may be interfaced easily to the Z-80.
Otherwise, the processor would have to wait while a separate cir-
cuit, called the refresh controller, stepped through the dynamic memory
rows refreshing the cells. The dynamic memory interface appears
in Fig. 2-29.
RFSH
A0 - All
dynamic ram
z-80
ADDRESS rus t AGE ]
z-80
PAGE 0
In Fig. 2-30, the timing of the Z-80 refresh cycle is presented. Note
how, whenever an instruction is fetched, we get a "free" refresh cycle.
Using the RFSH and MREQ signals, we can do a column refresh,
thereby maintaining our data.
In any other system one would have to provide an address multi-
plexer, column counter, and refresh control logic on each memory
board. Fig. 2-31 illustrates such a system.
51
1•
I
T1
CLOCK
MREQ
-7--r:-
WAIT _j_ - _\_
Ml
DB0 OB7
IN
RFSH
BUS BUFFERS
MEMORY
HIGH ADDRESS
ARRAY
LOW ADDRESS
BUS
AO -A7 MUX
8 BIT
ADDRESS
COUNTER RFSH STROBE
MA0-MA7
(READ WITHOUT
SELECT
DRIVING DATA BUS)
ADDRESS
RFSH REO
- - --~REFRESH
RFSH ACK
- - - - . . i CONTROL
SYS CLOCK
52
ASSEMBLING THE CENTRAL PROCESSOR
The Refresh Control Section will vary with each different micropro-
cessor bus timing specifications. Besides the timing, one must choose
the method of refresh.
The control section may wait 2 milliseconds and then refresh all the
columns, or it may refresh after every few instructions one column at
a time. The latter method is preferred, because it upsets system timing
the least. For a complete discussion, see "Dynamic RAM Interface,"
p. 240.
An efficient scheme is transparent refresh. This is what the Z-80
does automatically. If one knows the intricate timing of the bus exact-
ly, sometimes the designer can find a time in which the memory is not
being used. Then, during that time the hardware can "hide" a refresh
cycle.
Mostek, which second-sources the Z-80, produces a single-board
CPU, with 16K bytes of RAM, 20K bytes of ROM and various input-
output ports. The RAM bank consists of eight 16K by 1-bit dynamic
memories, and the ROM bank of five 4K by 8-bit ROMs. This one
board uses few chips to implement a powerful processor. Compared
to the 8080, the chip-count reduction is due to the elimination of the
8224 clock, 8228 system controller, and refresh logic.
THE 8085
Intel naturally also had to improve the 8080 design. Then, the 8085
reduces the parts count of an 8080 system while increasing the speed.
Essentially, it integrates the 8080, the 8224, and the 8228 into a single
chip.
This time, to provide expanded control functions, 16 address lines
and 8 data lines, the decision was made to multiplex the low eight ad-
dress bits. At the beginning of every instruction cycle, the low eight
address lines appear on the data bus. To be used, they need to be
latched. The multiplex control line ALE ("address-latch enable") is
used to latch and hold the lower address bits.
Fig. 2-32 shows the 8085 system. Right away it should be apparent
that no latch is used for the low address bits! Intel has created a new
line of special RAM, ROM, PROM, and input-output chips which
contain the low-address latch. Thus, the 8085 bus has 8 data, 8 ad-
dress, and 11 control lines.
The special peripheral chips contain combinations of RAM,
PROM, and input-output. In this way, complete systems with as few
as three LSI chips may be built. An 8277 PROM 1/0 chip is presented
53
MICROPROCESSOR INTERFACING TECHNIQUES
..
~
....y~~
s:>
HY
6V
2 --
-
-
/.
<
,.;
--gg_
IIV
s:n1
~,::,
-
.... - lE :Ii "
oo,.
i,.Qll
W./o/1
llM
all
«:: nv
- .,.,
.....
.......
t"'"' .. N
- 0
I
...,t
--- .. ..
.."' --- !'" ::,
.. 0
2 -
- .....
"' g.i
.."'
"'
..:J
r=
2
- ..
==
--
..
~ g
~
. .."'...
: lE
<
: "'
.,
;;
"'
.,...<
;
~
!::',
0
u
<
..
q
< -
.... --
2 -
-
- ..
~ !"
"'
>"'
1111
<ac<O u,;ic ► ~
...,,-03 ~
W...iOOll:lt:'6il-'
..
<
..
'<
...Cl !' -=:J._
:!:?i~;I: "'"'"'-:J"'<
... .. D
~ ;;; "'"'"'
I 6 .. .. ..
...
.... "'.,, .,.. "'"' ----=r
~
,0
++ +
i 1f f f
SJ..f0llll3.lNI
54
ASSEMBLING THE CENTRAL PROCESSOR
CLK
READY
DATA
ADDRESS
2K X 8
IOIM
RESET ERa-1
RD
ALE
ICYl'i
!OR
CE
_.c_ 1-----------1X1
55
3
BASIC INPUT-OUTPUT
INTRODUCTION
Memory-Mapped 1/0
56
BASIC INPUT-OUTPUT
57
MICROPROCESSOR INTERFACING TECHNIQUES
t-------------MEMR
TO
t---------.-----+---MEMW MEMORY
MPU
TO
1/0
Al5
MEMR
} TO MEMORY
MEMW
MPU
IOR
jro110
IOW
58
BASIC INPUT-OUTPUT
ROM
PIA
ACIA
RAM
.)
M OCA'ilm
SELECT ! I CHIP SELECT
+
ics
p
u w-.. L.J\ 1/0
--v CHIP
· REGISTER
SELECT
MEMORY
PARALLEL INPUT-OUTPUT
59
MICROPROCESSOR INTERFACING TECHNIQUES
·DATA BUS
TO DEVICE
ADDRESS BUS
60
BASIC INPUT-OUTPUT
The internal diagram of the 6820 appears in Fig. 3-9. It has six
registers, two sets of three registers per port. One set is for port A and
the other is for port B.
Let us examine the control register. Its format is shown in Fig. 3-10.
Bit 7 indicates a transition of the CAI input. It is used as an interrupt
flag. The same is true of bit 6, except that it monitors the CA2 pin of
CA2 used as an input. Bits 5, 4, and 3 establish the eight different
modes of the device and the function of the CA2 pin. Bit 2 indicates
whether the direction register or data register is to be selected, as they
have the same address. Bits 1 and O are the interrupt enable/disable
control bits.
A clarification is needed here: Motorola's PIA has 6 registers and
only two register select (RS) pins, because of the 40-pin limitation.
The DR and the DDR in each port share the same address! They are
differentiated by the value of bit 2 of the control register, a program-
ming nuisance.
Fig. 3-11 indicates how the registers are selected by use of the RSI
and RSO pins and the state of the internal bit 2 of the control register.
61
MICROPROCESSOR INTERFACING TECHNIQUES
DATA BUS
ADDRESS BUS
1/0 1/0
ADDRESS DATA
1/0 INTERFACE
STATUS
CONTROL BUS
. - - - - - - - - - O U T P U T BUFFER FULL
. . . . - - - - . - - - - - DATA RECEIVED
EN
3-STATE ~-./OUTPUT
LATCH
3-STATE
BUFFER
62
BASIC INPUT-OUTPUT
t
I DATA BUFFER 1 I I DATA BUFFER 2 I
l '
FUNCTION REG I I FUNCTION REG ' l
I
I STATUS I POWER
, I•
! MUX I CONTROL
LOGIC
zt- CHIP
SELECT
MICROPROCESSOR .CONTROL
DATA BUS SIGNALS
CAl
CA2
,.,,,
"'"' 0...z -,.,'
"' 0
"' ,.,
"'
DATA BUS .."',.,
~ ...
"'
,...
0
-"'
"'"
....
"'
,.,
-
..
0►
►
-
·"' c:,
►
,.,.."' ..
► m
"'-
,,
:r 1/0
"' "'!i "' "'r-►
..... o:s, 8
II II
REGISTER
SELECT
I RS0
RSl
~ ;;
"-4 -4
"
c:: c::
1/0
IRQA CB2
IRQB CB!
SELECTING PIA REGISTERS USES 2 LINES <RS0. RSll. PLUS BIT 2 0r CR:
RSI= 0 SELECTS PORT A REGISTER
RSl = l SELECTS PORT B REGISTER
RS0 = l SELECTS CONTROL REGISTER (A OR Bl
RS0 = 0 SELECTS DATA DIRECTION OR BUFFER REGISTER
........----- - -
-- · --;l~T~-----···1
RSl RS0 CRA(2l CRB(2l
0 0 0 DATA DIRECTION REGISTER ---:
0 0 1 BUFFER REGISTER A I
0 l CONTROL REGISTER
l 0 0 DATA DIRECTION REGISTER
. 00-07
CA\
CA2
. .>
RSO p
PA0-7
.. r
RSI
cso
I ~ .>
m A PB07
... r
CSI
E
RIW
.......-
,--
~ C62
MOA CBI
I ~+sv ~ .
<
I
- ... 1v-.: 11
Mil-.
Rll"i.
->
r
>
64
BASIC INPUT-OUTPUT
Fig. 3-12 shows the connection to the 6800 buses, and Fig. 3-13 il-
lustrates a typical application with the bits shown for the control and
data-direction registers.
CAl INPUTREADY
CA2 INPUTACK
...
DATA
'
DATA
00000000
00100111
..
DATA .,. OUTPUT
11111111
00100111
-
CB2 OUTPUT READY
CBl - OUTPUT REQUEST
As a last note on the 6820, it is a good idea to buffer the data bus
to this chip as it cannot drive a heavily loaded data bus. Fig. 3-14
gives a suggested buffering arrangement for the data lines.
65
MICROPROCESSOR INTERFACING TECHNIQUES
The 8255 contains four ports, two with eight bits each, and two with
four bits each. Each port can be programmed via the mode-control
register to be either all inputs, all outputs, or a special function. The
8255 appears in Fig. 3-15.
Table 3-16 indicates how the ports are addressed. There are several
modes of operation, where each half of port C is used for interrupt
flag inputs or handshaking signals. The Intel device is not program-
mable by bit, but offers 4 more lines for control. Overall, the func-
tions performed are essentially analogous. In fact, a PIA can be used
on an 8080 system, and conversely. Each major microprocessor
manufacturer has its own version of a programmable parallel inter-
face. Their function is essentially similar.
GROUP A
PORT A
GROUP A (8)
CONTROL
DATA
GROUP A
PORT C
BUS
UPPER (4)
BUFFER
GROUP B
R READ/ PORT C
WRITE LOWER (4)
cs___J
SERIAL INPUT-OUTPUT
66
BASIC INPUT-OUTPUT
-cs -
0
0
Al
0
0
AO
0
l
Ri5
0
0
WR
l
l
PORT A TO DATA BUS
PORT B TO DATA BUS
I
OPERATION
MPU
READ
0 l 0 0 l PORT C TO DATA BUS (A,B,C)
0 l l 0 l ILLEGAL
(DISABLE)
1 - - - - DATA BUS TO 3-STATE
MARK
--START------------...----i,---+---+------
LSB MSB
STOP 1
STOP 2
1 2 3 4 5 6 7 8
SPACE
- -- - - TIME
67
MICROPROCESSOR INTERFACING TECHNIQUES
ENTER ENTER
SEND DATA
BITS
SEND STOP
BIT
EXIT
RET
One of the earliest standard LSI devices was the UART. A UART is
a serial-to-parallel and parallel-to-serial converter. The UART has
two functions: to take parallel data and convert it to a serial bit stream
68
BASIC INPUT-OUTPUT
with start, parity, and stop characters, and to take a serial bit stream
and convert it to parallel data.
The functional block diagram of the UART appears in Fig. 3-20.
Each UART has 3 sections: a transmitter, a receiver, and a control
section. Almost all the manufacturers have a pin-compatible or "im-
proved" version of the standard UART.
PARALLEL
TRANSMITTER SERIAL
l /0
OUTPUT
CLocK==::
CONTROL STATUS
CONTROL SIGNALS
FUNCTIONS
I I _L
POWER
69
MICROPROCESSOR INTERFACING TECHNIQUES
The UART requires both an input port and an output port to inter-
face to a microcomputer system, so subsequent UARTs were designed
to be directly bus-compatible with microprocessor buses. Two of these
are: the Motorola MC6850 ACIA (asynchronous communications in-
terface adaptor), and the Intel 8251 USART (universal synchronous
and asynchronous receiver-transmitter).
ACIA
TDR
TRANSMIT
SERIAL
DATA
DATA OUT
RDR
RECEIVE
SERIAL
DATA
Df\TA BUS MUX DATA IN
SR
CTS
STATUS DCD
CR
CONTROL RTS
Fig. 3-22 breaks down the inputs and outputs into their functions:
the serial data, the modem control, the clocks, and the buses. The
serial data in and out are TTL-compatible signals and must be buf-
fered to provide the level necessary for driving serial devices. (See
Chapter 4 for a full explanation of how to connect a teletype to an
ACIA.) The modem control controls the interface required in an
RS232C modem link.
The clocks control the bit rate of the serial data and may be dif-
ferent for transmit and receive sections. The bus signals are the signals
used in a 6800 system. The truth table showing the addressing of the
internal registers appears on Table 3-23.
70
BASIC INPUT-OUTPUT
~ . ..)
<.... DATA BUS
..
~
D0-D7 TxD
r }sERIAL DATA
RxD
RS
- CSl DCD -
-- rn CTS !MODEM CONTROL
RTS
·- CS0
TxC -
-... ~/W RxC IRATE CLOCKS
..... IRQ
I ..L
+s ..
~
I ADDRESS BUS
....
< CONTROL BUS
..>
"
Fig. 3-22: 6850 ACIA Functions
RS R/W REGISTER
0 0 CONTROL
0 1 STATUS
1 1 RECEIVE DATA
1 l TRANSMIT DATA
71
MICROPROCESSOR INTERFACING TECHNIQUES
The block diagram and control signals for the 8251 USART are
shown in Fig. 3-24. This device differs from the ACIA: it also pro-
vides synchronous data transmission and reception, in addition to
asynchronous transmission. (Motorola supplies a separate USRT, the
"SSDA" for synchronous communication.)
The 8251-to-8080 system interface appears in Fig. 3-25. Some of the
internal circuitry of the 8251 is dynamic, hence the need for the <p2
clock signal. The rest of the signals are straightforward.
The USART has five internal registers: receive data, transmit data,
mode, status.and control. Upon reset, the first byte sent to the 8251 as
control will set the mode. The next byte sent as control will be latched
in as control. The mode determines whether the 8251 is to be used in
synchronous, or asynchronous, mode. The control indicates the word
length and other transmit parameters. Table 3-26 is a truth table of the
8251 bus control signals.
·RESET
CLK
clii
RO
WR CONTROL
DSR
MODEM DTR ..
CONTROL
CTS
m .. ~o
cs
72
BASIC INPUT-OUTPUT
8251
Rd C~ CRT
TERl!INAI.
Td 1 - - - - - - - - + - - . t COIIT~Ol.lER t([YIOAAD
C/D RD WR CS OPERATION
73
MICROPROCESSOR INTERFACING TECHNIQUES
74
BASIC INPUT-OUTPUT
MEMORY
DATA BUS
MPU
L._ _ _ _ _ _ _ _ ?,
1/0 1/0
L... - - - - - - - - - - - - - - - - - _J?
MEMORY
MPU
1-----------,-,.-----..-,.--- INTERRUPT
INT! 1/0
INT
HOLD
MPU
75
MICROPROCESSOR INTERFACING TECHNIQUES
YES
SERVICE ROUTINE
FOR DEVICE A
YES
SERVICE ROUTINE
FOR DEVICE B
YES
SERVICE ROUTINE
NO FORDEVICEC
Interrupts
The polling technique has two limitations:
1. It is wasteful of the processor's time, as it needlessly checks the
status of all peripherals all the time.
2. It is intrinsically slow, since it checks the status of all VO devices
before coming back to any specific .one. This may be objectionable
in a real-time system,. where a peripheral expects service within a
specified time. In particular, .when fast peripherals are connected to
a system, polling may simply not be fast enough to satisfy the mini-
mum service requirements. Fast devices such as the floppy disk or a
CRT require a near-instantaneous response time in order to trans-
fer data without loss.
Polling is a synchronous mechanism, by which devices are serviced
in sequence. Interrupts are an asynchronous mechanism. The princi-
ple of interrupts is illustrated in Fig. 3-32. Each 1/0 device, or its con-
troller, is connected to an interrupt line. This line will gate an interrupt
request to the microprocessor. Whenever one of the 1/0 devices needs
service, it will .generate an interrupt pulse or level on this line to re-
quest the microprocessor's attention.
76
BASIC INPUT-OUTPUT
INDIVIDUAL
INTERFACE ·
DEVICE
FLAGS
CPU
DECODED
ADDRESS
77
MICROPROCESSOR INTERFACING TECHNIQUES
This is the purpose of the mask bit (or mask register when several
interrupt levels are available) in the microprocessor. Whenever the
mask bit is on, interrupts will be ignored (see the chart in Fig. 3-33).
The "mask,, facility is also often called the "enable.,, An interrupt
will be enabled whenever it is not masked.
J 6 5 4 3 2 1 r,
I I I I I I III
0 0 0 No service requested
0 0 1 Device 1 on Port 1
0 1 0 Device 2 on Port 2
1 1 1 Device 7 on Port 7
Bus Ori't"tr
..
-
~
Priority V
E...-r
~
D111 Bus
..
7
8
5
4
3
2
1
N 0
y
1
3 btt
Stltuspo,t In
binary oocM
of input with
higt,HI prlo,ity
78
BASIC INPUT-OUTPUT
1/0 110
ll'U
INTERFACE l
••• INTERFACE N
INT
. __ _ _ _ _....._.......... _ __ _ _---1 INT N
INTERRUPT LOGIC
EXECUTE
INSTRUCTION
NEXT INSTRUCTION
Once the interrupt request has been received, and accepted, by the
microprocessor, the device must be serviced. In order to service the
device, the microprocessor will execute a specialized service routine.
Two problems occur.
First, the status of the program in execution on the microprocessor
at the time of the interrupt must be preserved. This implies saving
away the contents of all the registers of the microprocessor. These
registers will be preserved in the stack. At the very minimum, the pro-
19
MICROPROCESSOR INTERFACING TECHNIQUES
SET MASK
PRESERVE REGISTERS
UNSET MASK
IDENTIFY DEVICE
ilflllCHMfy
EXECUTE ROUTINE
RESTORE REGISTERS
RETURN
80
BASIC INPUT-OUTPUT
MICROPROCESSOR MEMORY
SP I I
INT
- !GENERAL
~g_~~"!.~~
lB
pp f!❖!•!❖!•!~•!•!•!•,•!•,••I
c::::::J
1
NEXT INSTRUCTION
► INTERRUPT ROUTINE
ADDRESS OF INTERRUPT
INTERRUPT VECTOR
.___ _,
ROUTINE IS LOADED
INTO PC
signal that the device did request the interrupt. Having identified the
device which has triggered the interrupt, it will then branch to the
appropriate interrupt-handling-routine address. The order in which
the polling is conducted will determine which device is serviced first.
This implements a software-priority scheme, in the case where multi-
ple devices might have triggered an interrupt at the same time.
INTERRUPT
OUT
OUT
(RTI)
(RTI)
81
MICROPROCESSOR INTERFACING TECHNIQUES
INT .__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __
1N
(1 TO N LIN.____._..
T INT INT
1 2 ••• N
ACK
I ,D,
DATA BUS
82
BASIC INPUT-OUTPUT
Priorities
83
MICROPROCESSOR INTERFACING TECHNIQUES
cessor data bus or sometimes on its address bus. This causes an auto-
matic branch to the specified address. Naturally, these registers are
loaded by the programmer. A recent PIC design is shown in Fig. 3-39.
DATA BUS
INTO
INT l
INT2
INT3
INT
INT4
INT5
INT6
INT7
MASK REGISTER
DATA BUS
INTO
INT 1
INT 2
INT 3
INT4
INT 5
LEVEL INT 6
VECTOR INT 7
INT
IRO LOG IC
INT OETECT
84
BASIC INPUT-OUTPUT
-u, --7
INSTN INST\I 11
RETURN
I
I
I ..,
CONTROL UNITr- 1
TRO TB TH Ts
85
MICROPROCESSOR INTERFACING TECHNIQUES
TIME
PROGRAM P
INTERRUPT1
INTERRUPT2
INTERRUPT3
--~-
1-----1 - - - - - -
I l
STACK
[~]
I
t,
ffi
T2
[:]
I
13
ffi
T4
[:]
I
T5
86
BASIC INPUT-OUTPUT
s INTA INT
(8228)
CASil
CASl
~~:~~,
C°"PAAATOR RfS(T
CAS2
IHITIAUlATICl4 11111
~
R/W IOI) :t-!m'la:
w LOGIC
)Of
PRUJUlY
CffllloTl04 lllilSIIR IIIIBRl'T
A C(HW() A(Q.('Sf
c O()j
IIEGJSTER
IR7
DATA
II.JS
Bl.HEIi
8228 Pl!O!lUCES 3 INTA PULSES
8259 PLACES A 3-BYTE CALL ON om BUS
87
MICROPROCESSOR INTERFACING TECHNIQUES
t HOLD
DMA ~ PERIPHERAL
INT
88
BASIC INPUT-OUTPUT
Hi 8
• ~ •.;.lo.
. "11-7
. 8 8
•nsTB
. 4 .> DMA
<
A8- l!i
?
l .. REQ'1ESTS
2
T
. EN
4 .
,..
< 11-7 ..
~ OMA
AC KNOWLEDGE
--
cs
.
,..
.. CONTROL
SIGNALS
MARK
TC
.. •
r
89
MICROPROCESSOR INTERFACING TECHNIQUES
90
BASIC INPUT-OUTPUT
16 8
• ~
."""' "11-7
,
"
. 8 8 . 4 .
' A8-15
2
l
~-.:sTB
.
') 0"-A
REQU'ESTS
2
T EN
... 4 .) D"-A
IC ll-7 . ACKNOWLEOGE
"
cs
. . CONTROL
"ARK i - - -
TC f---
SIGNALS
" • p "
CONT ROL ADDRESS n} A
BUS BUS BUS
CS/TxAKB
R/W
il2DWI A0-15 ADDRESS
RESET
DGRANT
DRQT
6844
DRQH
TxADA
·· -· -
TxSTB
IRQ/DEND
TxRQ0
TxRQl Drl-7 DATA
TxRQ2
TxRQ3
vss \c
91
MICROPROCESSOR INTERFACING TECHNIQUES
TRI OMA
ADDRESS BUS STATE /4- ADDRESS .I'--
,{ J, ·,U, DRIVE'!
"""'
COUNTER "'"' TRI
... DMA
ROM RAM DMA
- STATE
DJIIVER
lo-
1-- DATA
SOURCE
WORD
I'--
.....,...
6800 COUNT
~ ~
·1 ~ REG I STER
DATA BUS
R/W
DBE DMA
<t-i-
YMA CONTROL
I
I
- ;
CLOCK 02
HOLD
'1PU OMA RAM PIO
STACK
ADDRESS BUS
RIW INT
92
BASIC INPUT-OUTPUT
DRQ0
DISK 1
8257
DISK 2
+ RAM
8212 DISK 3
DISK 4
I/OW I/OR
SUMMARY
The basic input-output techniques and components have been pre-
sented in this chapter. In an actual system, the designer will select the
combination of hardware and software algorithms required to meet
his performance criteria and cost constraints. More chips will be in-
troduced in the future which offer still greater efficiency for high-
speed input-output management.
Before leaving the CPU interface and 1/0 problems, there are
always some simple circuits required to tie a system together.
Presented in Figures 3-52 through 3-57 are some useful circuits. These
include one shots, a reset circuit, and code conversion. They are
described below.
The next, and most important, problem to be solved, is to interface
the peripherals. This will be done in Chapter 4.
93
l,C
~ ~
~ XTAL
R
<;:: OMA ACKNOWLEDGE lL~
SYSTEM DATA BUS
2'"):. OMA ACKNOWLEDGE JJ ~Dr ;c
0
"'C
;c
* 0
()
OMA REQUEST OMA REQUEST m
~YIN (/)
l
4 • 3 ,Alv\8224 (/)
~
ric' +5 w +s --I STSTB
0
;c
0 o· 0 J> )> ::c 0 0 )> )>
8 g z-4
,~ Ii
0
'O 0
J>
... 0 5 "' ')>"' z~ 0
~
...
I
fJl
"'
D '"' 0
.....
0
~
C/l
(!:
m
z )>
'"'
D C/l
oJ zm o
'-I
. I I l/~2:TL) ~~SIN m
;c
RESET
r- -
~
AM9517 RESET _AM9517 CLK >- "T1
"'
fJl
.....
] IJ I I
• I
! II l
I
It I I t t I .i: z
c"'
~"'
::c: ~
,_
"'
,_
"'
"'
G)
-4
m
n
I
'
<Xl
~
~
~ ~ A 8-Al5 ~◊,
3 '------------tY3 S4 A
I"
Cl4 •
'0
~
I.
T I
AM8080A
"' "'
ADDRESS BUS A,c:A15
AM9080A
BASIC INPUT-OUTPUT
TIMING ELEMENTS
INPUT
OUTPUT
INPUT n
I
I
I
OUTPUT
II II
Fig. 3-52: One-Shot Stretches Pulses
95
MICROPROCESSOR INTERFACING TECHNIQUES
its reliability is usually less than that of the other elements in the cir-
cuit. It is by its very nature more sensitive to power supply noise and
decoupling problems. It is considered good design practice to try to
avoid using one-shots as much as possible. A typical one-shot is il-
lustrated in Fig. 3-52.
MUL TIP'LEXflt
I
---0
---0
----0
SlMll .\it 10
---0
ADDRF,SS J"()'.';lTIO ~ t!li Sl'VC"Ttn
lf'I' A[)[)IU.SS l!lirt·rs
96
BASIC INPUT-OUTPUT
I'
-
~
MPU RESET ··
Along with these devices, which are the needle and thread of a
system, there are other applications for ROMs besides storing pro-
grams. In Fig. 3-56, the use of a standard ROM is illustrated as a code
converter. Inserting this ROM in the parallel data path between the in-
put device and the microcomputer, or between the microcomputer and
the output device, will convert your ASCII code to EBCDIC code.
Other conversion schemes are also possible. Another use is as a soft-
ware watchdog. A ROM pattern is generated from a pattern derived
by using a logic analyzer. That static pattern is then compared with the
same information which generated it. lf there is ever a change, this
would indicate a possible software failure. In Fig. 3-57, the elements
97
MICROPROCESSOR INTERFACING TECHNIQUES
RESET
+5~
Al5 >-4-----~--
NEW Al5
of this watchdog circuit are shown. Once a software failure has been
detected, the hardware can interrupt the microprocessor. This inter-
ruption will tell it that a software failure has occurred. Self-check pro-
grams may be run at this point to try to determine the cause of the
problem.
::: -
--
-
1702A -
---
[ ---
,...
PROM
--
J]
INPUT
Its 0 UTPUT
CHECK INTERRUPT ON
ADDRESS
A8-A15;
J\ ROM SOFT-FAIL DETECT
)
y
256X4
X - A
4 . _A=B
LOW 4DATA COMPARE. ,~
-
~
-- -
--
B
- -
- RD 'i
Fig. 3-57: Software Failure Detect ROM with Table Derived from
a Logic Analyzer
98
BASIC INPUT-OUTPUT
99
4
PERIPHERAL INTERFACING
INTRODUCTION
Now that the CPU, memory and input-output are connected and
working, how do we connect to the teletype in the corner? What about
the paper-tape punch, keyboard and telephone line? These are all
peripherals that allow the user, or another computer, to communicate
with the system. In this chapter, a number of common peripherals will
be interfaced:
- Keyboard (including ASCII keyboard)
- LED Display
- Teletype (TTY)
Paper-tape Reader (PTR)
- Stepping Motor
- Magnetic Stripe Credit Card Reader
- Tarbell Interface
- Cassette Recorder
- CRT Display
Floppy Disk
- Music Synthesizer
- Dynamic RAM Interface
KEYBOARDS
100
INTERFACING THE PERIPHERALS
Bounce
One of the most common problems with a single switch is bounce.
Keybounce refers to the fact that when the contacts of a mechanical
switch close, they bounce for a short time before staying together.
This is also true when the switch opens. Fig. 4-0 is a time-versus-
resistance plot of a typical switch contact.
KEY
DEPRESSED ... 1
The solution is to wait for the status of a key to remain stable for
perhaps 20 milliseconds. This may be done by hardware-filtering or by
a software-delay routine. The hardware circuit appears in Fig. 4-1 and
requires the same circuitry for each key. This circuit is useful for the
few front-panel switches in a system. In the case of a larger number of
keys, software is often used.
101
MICROPROCESSOR INTERFACING TECHNIQUES
+5V
+5V
0 1 2 3
4 5 6 7
8 9 A B
C D E F
Non-Encoded Keyboard
102
INTERFACING THE PERIPHERALS
·OUTPUT OUTPUT
Il I I I I II I I
- I
/
/
/
/
/
~·/
/
T
... '
• / /
I
• / / I
-
I
/ / / /
-• - Io
2
I• I l •I 0 0 ii
-.
t .
...
, •
1
- I
I
~,
-
I 2
•
-
I
Larger keyboards require more select or sense lines. Fig. 4-4 shows
how a four-to-sixteen-line decoder allows for a 64-key matrix with
four bits of output and four bits of input from the microprocessor
1/0 ports. Fig. 4-5 shows a simple twelve-key matrix using four output
bits and three input bits on an F8 microprocessor system.
4 ... 16 )
) 4:16
,
DE ROW 16 X 4
MPU CODER SELECT KEYBOARD
.. 4
COLUMN SENSING
103
MICROPROCESSOR INTERFACING TECHNIQUES
F8
.COL0
Rollover
Rollover is the problem caused when more than one key is held
down at the same time. It is essential to detect this fact and to prevent
wrong codes from being generated. The three main techniques used to
resolve this problem are the two-key rollover, the n-key rollover, and
the n-key lock-out.
Two-key rollover provides protection for the case in which two keys
are pressed at the same time. Two techniques are used. The simplest
two-key rollover simply ignores the reading from the keyboard until
only one key closure is-detected. The last key to remain press·ed is the
correct one. This philosophy is normally used when software routines
are used to provide keyboard scanning and decoding. The second
philosophy is often used by hardware devices. The second key closure
is prevented from generating a strobe until the first one is released.
This is accomplished by an internal delay mechanism which is latched
as long as the first key is pressed. Clearly, for better protect ion, roll-
over should be provided for more than two keys.
104
INTERFACING THE PERIPHERALS
N-key rollover will either ignore all keys pressed until only one re-
mains down, or else store the information in an internal buffer. A sig-
nificant cost of n-key rollover protection is that most systems need a
diode in series with every key in order to eliminate the problem created
when three adjacent keys at a right angle are pressed ("ghost key").
This increases the cost very significantly and is seldom used on low-
cost systems.
N-key lock-out takes into account only one key pressed. Any addi-
tional keys which might have been pressed and released do not gener-
ate any codes. By convention, it may be the first key pressed which
will generate the code, or else the last key pushed. The system is
simplest to implement and most often used. However, it may be objec-
tionable to the user, as it slows down the typing: each key must be ful-
ly released before the next one is pressed down.
Line-Reversal Technique
The basic technique used in identifying the key which has been
pressed on a keyboard is row-scanning, as described above. However,
because of the availability of the universal parallel interface chip, the
PIO, another method can now be used. This is the line-reversal techni-
que. This method will use a complete port on a PIO, but will be more
efficient software-wise (faster). This method is illustrated below. In
the example, a 16-key keyboard is used. One port of the PIO is dedi-
cated to the keyboard interface. The identification of the key is per-
formed in essentially four instructions only. In practice, some more
instructions may be needed, because of the specific structure of the
PIO used .
105
MICROPROCESSOR INTERFACING TECHNIQUES
PIO
106
INTERFACING THE PERIPHERALS
OUTPUT II
I 0
I I
I I
I
- ,_ --
0 I
- ,_
- - -·
I I
0 0
INPUT I I
0 I
--
0 I - l
L- - --
I
- -..,
PIO
107
MICROPROCESSOR INTERFACING TECHNIQUES
Encoded Keyboard
Not everyone enjoys writing the software required for keyboard en-
coding. Various types of LSI interface circuits are used to encode
keyboard. Usually, the circuit will scan the matrix, discover a coin-
cidence, provide for some amount of debounce and rollover, and latch
the data for use in the system. Some units also provide an internal
ROM look-up table to generate the proper code for the key pressed,
such as ASCII or EBCDIC.
With this one chip and the microcomputer system, a complete entry
and display interface is acomplished. Note in Fig. 4-13 that the 8279
forms -the complete entry and display section interface for a point of
sale terminal using the 8048 single-chip microcomputer system.
Keyboard Encoders
The basic role of the keyboard encoder is to identify the key which
has been pressed and to supply the 8-bit key code corresponding to it.
In addition, a good keyboard chip should also solve the problems we
have described above. It should debounce and provide rollover-
protection. Three essential types of encoders are available: static en-
coders, scanning encoders, and the converting encoder.
A static encoder simply generates the code corresponding to the
key. In order to simplify the key-protection problem, the linear
keyboard can be considered. A linear keyboard is, for example, a
64-key keyboard which provides a wire for every key pressed. Detec-
tion here is easy. The pulse appears on the wire corresponding to the
key pressed. This pulse is then simply transformed into the suitable
8-bit code. However, this means 64 separate incoming lines to produce
one of 64 8-bit codes. In order to reduce the cost of the wiring and the
necessity for encoders, most keyboards are arranged in matrix
fashion, for example 8 by 8. In an 8-by-8 keyboard, only 16 wires are
used. The price paid is that the process necessary to identify the key
becomes more complex. This then requires a scanning encoder, or the
use of a scanning routine. Expensive ASCII keyboards (full
keyboards) can afford the luxury of a linear arrangement in view of
the cost of every key. No scanner is then necessary to identify the key.
However, most keyboards have the matrix arrangement.
Scanning Chip
A scanning chip solves the problem of key identification when using
108
INTERFACING THE PERIPHERALS
5
4
6 - BIT 3
COUNTER 2
1
0
CLOCK ROW -
OSCILLATOR
SCANNING
STOP
OF
Bx8 8
KEYBOARD DE-
109
MICROPROCESSOR INTERFACING TECHNIQUES
-
- ---
.
7(PARIT
.
- --
6
L
-
.
5
-
-- ROM
-
4
3 CODE
A
-
-
-
...
-
2
T
C
SHIFT - 1
CTAL -- - 0 H
STROBE-----------------------'
LATCH PROVIDES n • KEY ROLLOVER PROTECTION
110
INTERFACING THE PERIPHERALS
v.. ~ I l II -
j
.
:
I
f 10 BIT COMPA~lOR
10-STAGE
RING COUNTER
...
I
~
I~~-~:~•-~
'i
( (
( TIMJNG i--....,:.3... STR8E I
I V CtOCUIT I .L OflAV
(_ -~ If Y10Jvt,'.Jv Y,ktv.lvf,': Y
SHIFJ __J_ MOOE ~ ;: :2
~ 9
I OE
cONTROl - - . cooeA:
f -
~ 3600 en ROYi
(1081Jx9<»:EYS
~===.:::!
/:===~
~=::t::t===:+=!437j=:=~x!t,=t:l=l:l=l=t:~~~~
STACE
~=:t.:t.===-:=:.f:==j~t=t=.b=.b~::l:i~l-
•tNG
31> X3
f K4MODE) I----ICOUNTERl--++--+-;:;:-..;;:'--~1-+-,l-+-,~4-
( •2 X9
I
I
I
I
I
I
111
MICROPROCESSOR INTERFACING TECHNIQUES
SHIFT
KEYBOAR'.l
MATRIX
CONTROL
8 8 COLUMNS
RI'TURN 8 ROWS
LINES
5V 8
-BIT
MICROPROCESSOR 1 of 8 DECODER
SYSTEM DATA , __ _-"'I
BUS
3
~ONTR~~i 1-------" 82?9 s~-3 ,,__ __,,_ ___
(DECODED)
_ _ _ ___, DISPLAY
CHARACTERS
- - - - ~ - - -.... ~ATA
DISPLAY
ASCII Keyboard
112
INTERFACING THE PERIPHERALS
CAS.H0"4.a.w --:J._
Ki:Y S'IW'ITCH c:::l XTAL
TOTit-lS
AUDIO INOttATOA
.
8748/1048
PROMIROM
LT
0
RAM
1/0 TIMER . ~ )o
\ : c~:T~~~~~ATIONS
INTlAFACE:
• AEA0£A
lNTEflROP"'f • STOAE. ANO FORWARD
I < >
--'\, 8271
DATA• STROH
STlll''E,- MOTOA --v' KEYBOARD DISPLAY
CONTROL
'APE~ AOVANCt
StATUS
I
SCAN LINIS
FRONT ANO
ftEAIII OVA L
< ~ 01SPI.AY
> >
CASN RtCISTI:,- KEVIOAl\0 8 18181 Jm:, 1s~
MATRIX "UNllR' • NUMEAIC
WITHf'Al"E:A • oo•T.
ADVANC( • ITEM
• TA X INOICATOfl LAMP MATIIIIX FOR
• E.TC. H.LUMINAfED Kl!Y TOl'S
BIT NUMBERS
0 0 0 ·o 1 1 l l
0 0 1 l 0 0 l l
1 0 l 0 l 0 1 0 l
'
' ' ' ' ' ' '~
b7 b6 b5 b4 b3 b2 bl
0 l 2 3 Ii 5 6 7
a
0 0 0 0 0 NUL OLE SP 0
'
p . p
9 0 0 l 1 SOH DCl ! 1 A Q a q
0 0 l 0 2 STX DC2 • 2 B R b r
0 0 1 1 3 ETX DC3 I 3 C s C 8
0 1 0 0 4 EOT DC4 $ II D T d t
0 1 0 1 5 ENQ NAK s 5 E u e u
0 1 1 0 6 ACK SYN
•, '
6 p V r V
0 l l 1 7 BEL E'l'B 7 G w g w
l 0 0 0 8 BS CAN ( 8 H X h X
1 0 0 1 9 HT EM ) 9 I y 1 y
l 0 1 0 10 LP SUB • : J z J z
..I·-
l 0 l l 11 VT ESC + ; K [ k
l pp PS . <. L
',.
l 0 0 12 l
l l 0 l CR GS - M ) m I
-
l3
l l l 0 14 so RS > N n
l l l l l'"> SI us I ? 0 D 0 DEL
113
MICROPROCESSOR INTERFACING TECHNIQUES
is locked out while transmitting. The serial clock runs at 16 times the
bit rate. For 110 baud, the oscillator is tuned to 1760 hertz. For 300
baud, it is tuned to 4800 hertz.
u
A
R Rl
T
R2
FROM KEYBOARD
STROBE
TIMER-
BAUD-RATE
OSCILLATOR -
-6(5T
Bl .l. B2
BAUD-RATE SELECTION
Fig. 4-15: ASCII Serial Keyboard Interface
LED DISPLAYS
114
INTERFACING THE PERIPHERALS
+5V
NPN Transistor
Seven-Segment LED
A seven-segment LED display consists of a group of seven elemen-
tary LEDs arranged as in Fig . 4-17.
A
/'$ A./1
►/ ►/
/'V /"\/
F B
A/I A/
A/Al'!
...., ►{
G
Alf A.JI
E C
/'JI
115
MICROPROCESSOR INTERFACING TECHNIQUES
./ I
A
;-I I LI
I
-
,-
./ I ,-
G
1-
I
- -I I
If 1-,
_I I LI 7
-, ~
If
LI
1= ,-
0
LI I_ I
-
I I
- I
-
I I /_/ '- /~/
Fig. 4-18: Seven-Segment Characters
numerals and also drive the LEDs directly with internal driver tran-
sistors. An example is the 7447 pictured in Fig. 4-19. An output port
may drive the 7447 with four bits of BCD data to light the proper seg-
ments. The truth table appears in Fig. 4-20.
OUTPUTS
116
.. ·- - --------- ---
TRUTH
- - - - -- TABLE
- - - -- - -
INPUTS OUTPUTS
I l I I
DECIMAL
OR
ll!j
FUNCTION LT
,, ,
RBI D C 8 A
,,
Bl/ABO
• b C
, d • f g NOTE
,,
rJQ•
.
~
,
0
, X
0
0
0
0
, ,
0
0
0
, ,
0
,
0
0, , ,
0
0
0 0 0
1
I 2 X 0 0 0 0 0 0 0 1 0
.N.
~ 3 1
,, X 0 0 1 1 1 0 0 0 0 1 1 0
t
4
5
X
X
0
0
1
, ,
0
0
0
,
1 1
0 , 0
, 0
0
1
0
1 0
0
0
0
"-I 6
7
1
, X
X
0
0
1
1 , ,
1 0
,
1 1
0
1
0
,
0
0
0
1
0
1
0 0
1
z
-=-
'"'
C
-1
8
9
10
1
1
,
X
X
X
1
1
1
0
0
0
0
0
1
0
1
0
1
1
1
0
0
1 ,
0
0
0
0
1
0
1
0
0
1
0
0
0
1
0
0
0
~
,,
,t,
)>
I'
~
~
11
12
1
1
X
X
1
1
0
1
1
0
1
0
1
1
1
1 ,
• 1
• 0
0 0
1
1
1
1
0
0
0
n
z
13
14
1
1
X
X
1
1
1
1
0
1
1
0
1
1
0
1 ,1
1
1 0
0
1
0
0
0
0
0
G)
-t
I
15
Bl
1
X
X
X
1
X
1
X
1
X
1
X
1
0
1
1
1
1
1
1
1
1
1
1
1
1 ,
1
2
m
..,,
m
RBI 1 0 0 0 0 0 0 1 1 1 1 1 1 1 3 ,t,
LT 0 X X X X X 1 0 0 0 0 0 0 0 4 ..,,
I
m
,t,
~
)>
,-
_.
~ (/')
MICROPROCESSOR INTERFACING TECHNIQUES
In order to save the cost of having one decoder for each LED digit
display, the displays may be multiplexed. Each digit is on for a short
time before a new digit is selected and turned on. In this way, one
decoder can serve a number of displays. There are many ways to
multiplex. Two are presented here:
Fig. 4-21 shows the first scheme, which scans both digit and data.
Note how ixternal drivers are used. This is because, when multiplex-
ing, each display must be N times as bright as when it operates alone,
since it is on 1/N times as long. Thus, currents needed are N times as
large. Most integrated circuits cannot provide this current, so external
discrete transistors must be used.
-- BCD
TO
7-SEGMENT
DECODER
l
SEGMENT
ORIVERS I
.
.-,
I I
++ •! '
[ DIIIT
l l Dl~IT
,I
••• I DlijlT
I
I
'
I
OIGI T
SELECT
I
I
DIGIT
DRIVERS
I
Fig. 4-21: Multiplexing LEDs
The second scheme, in Fig. 4-22, uses a counter to advance the digit
count. The count is input to the processor and is used to address the
proper data for the digit. The data are placed on an output port which
drives the 7447 decoder. Note again that current-buffering is needed
to increase the brightness.
118
•
INTERFACING THE PERIPHERALS
PNP 7 DRIVERS
4 BIT 7447 ONE FOR EACH SEGMENT
DATA BUS lATCH
NPN
~ DISPlAY DIGIT DRIVERS
DECODER
COUNTER
2 BIT
•••
INPUT PORT
D"ATA BUS
Matrix LED
The LED matrix consists of five rows of seven columns of LEDs.
These 35 LEDs can display upper and lower case letters and numbers.
A typical arrangement appears in Fig. 4-23.
7 X 5 DOT MATRIX
CHARACTER
ROM
-
A f)
7 ROWS ■ ■ •0 0• •0
•
r
AO 0
- ■ D 0 □ □
R6 •••••
D
• □ 0 0
D
• 0 D 0
A7 ■• ■ ■ ■
AS A9 A 1
C HARACTEA
TO BE DISPLAYED
tfttt
Cf)' C4
DATA
DECODER
~ l 1
T
_n_
COUNTER
CLOCK
119
MICROPROCESSOR INTERFACING TECHNIQUES
AO 2048 x 8 C
Al ADDRESS 0 3T05
A2 L
u
OUTPUT A3 IN M DECODER
N
A4
PORT AS DATA DISPLAY
A6 OUT N .C.
A9
Al0
cs
OUTPUT
PORT
Summary of Displays
120
INTERFACING THE PERIPHERALS
OUTPUT ENABLE
AO
o,
• •
A4 • •
• j • •
5184 BIT
• • OUTPUT
• •
l
•
ROM MATRIX LATCHES
64 X 9 X 9
• • •
• •
A5
ROW
•
• I
•
• 09
READ
~ • S,,,.11..., ~,._.,,.,. r,,. <._...,. •• r~r,• .,.,,. ,.,.., "~ fl! J ,01 ~,... ,.,., :.r ,,,, ,.,,.. ,...,. Al I•• ,n- '-lol4w1'1
- - - - - - --·•·- ------- - -------------------------- -------'
121
MICROPROCESSOR INTERFACING TECHNIQUES
TELETYPE
DATA
33 !TY
+sv SET TO:
-20 MA LOOP
UART
SEND
In Fig. 4-27, the UART is used for serial to parallel and parallel to
serial conversion of the data. Fig. 4-28 illustrates the serial format,
and Fig. 4-29 illustrates the timing sequence. The schematic of the
interface shows how the TTL signals are converted into 20 milliamp
current loop signals required by the TTY.
122
INTERFACING THE PERIPHERALS
STOP 1 STOP2
MARK
SPACE
H LSB MSB
DATA READY
TRANSMIT ~
BUFFER
LOAD
SERIAL_._
Rx DATA
OUT
4
6850
ACIA TTY
hDATA
I
I
L _____ 4N33 _____ ....J 6
- nv
Fig. 4-30: Opto-isolated TTY Interface
123
MICROPROCESSOR INTERFACING TECHNIQUES
version. These are the MC1489 and MC1488 integrated circuits. There
are four translators in each package so a number of lines may be
interfaced.
MC 1489
Rx _/ '"'IH 41 "UT
6850 RS-232
DATA \..
ACIA COMPATIBLE
TTY.
MC 1488
Tx
DATA - SERIAL IN _
-
124
INTERFACING THE PERIPHERALS
When the start bit comes in, two things happen: the clutch engages
all mechanical linkages so that a print cycle will occur and prepares the
decoding selector magnet for the decoding process. The next eight bits
come in, 9.09 milliseconds apart. They each trip the selector magnet,
which stops eight notched wheels from spinning-one after the other.
In turn, the print bars which select the character on the print head are
raised, or lowered, due to the combination of notches on the wheels.
The print head selects the proper character and the print hammer
strikes the head onto the ribbon and paper. The stop bits are required
to allow enough time to finish the present character before another
comes along.
If the punch were on, the selection of the print bars would also send
punches through the paper-tape, while printing the character.
When a key is pressed, the proper bit pattern is placed on eight con-
tacts on the distributor. The distributor is like the spark distributor in
an automobile. Fig. 4-33 illustrates the simplicity of this scheme. The
motor is engaged to turn the commutator around once, which opens
and closes the loop generating the 11-bit pattern for that key.
TTY DISTRIBUTOR
•
I
L OUTPUT
l
-·
,,
--✓o--v
-/'>
COMMUTATOR
KEYBOARD
ENCODED
.,___S_WcrlT~
CLUTCH
TO
MOTOR
:==::===-(:::y_____.Cl
Fig. 4-33: Distributor in Teletype
Note that the synchronous motor is the timing source for the
125
MICROPROCESSOR INTERFACING TECHNIQUES
ENTER ENTER
SEND DATA
BITS
SEND STOP
BIT
EXIT
RET
126
INTERFACING THE PERIPHERALS
+s
8080
DATA LATCH 4
TTY TX DATA
8 -lOV~
PORT 2 430/W
127
MICROPROCESSOR INTERFACING TECHNIQUES
The counter register B is set at value 11, and the character which
was preserved in register C is loaded into the accumulator A. The
accumulator is ored with itself (third instruction). This does not
change its contents, but guarantees that the carry is set to 0. This will
be the start bit. A left rotate is performed: RA·V. This moves the
carry into bit position O of the accumulator. The output then occurs:
OUT2. The bit is sent to the teletype. Everytime that the bit is sent to
the teletype, a delay loop must be executed to guarantee a 9 ms delay.
The delay routine is implemented as subroutine, and appears at the
bottom of the program. Next, an RAR is executed to shift the correct
next bit into bit position. The carry is set in anticipation of ulterior
rotations to guarantee that eventually the start bits will be transmitted
correctly. The bit-counter (register B) is then decremented and tested.
If the counter reaches the value of 0, the program ends. If not, the
program loops by going back to address MORE, where the next out-
put occurs.
READ STATUS
NO
NO
LOSS OF
CARRIER ERROR
ROUT INE
LOAD
CHARACTER
RTS
128
INTERFACING THE PERIPHERALS
The first instruction loads the status of the ACIA into accumulator
A. The ready-to-transmit flag is in bit position 1, so it must be shifted
twice to the right, into carry, to be tested. If we are ready to transmit,
the program goes directly to DATA where the contents of accumu-
lator B are sent to the ACIA.
If the ACIA were not ready to send, the CTS bit would be checked;
if it were clear-to-send, a carrier loss would be indicated and the pro-
gram would branch to an error routine. If the ACIA is clear-to-send,
the transmit-ready flag would be checked until ready. This is a polling
technique. Interrupts could also be used.
PAPER-TAPE READER
The teletypewriters usually are slow for reading punched tapes. One
helpful peripheral would be a high-speed paper-tape reader. Such a
device would optically detect the code pattern on the paper-tape and
advance to the next frame quickly. A typical reader has the schematic
ra~--~)· -
shown in Fig. 4-39.
SCHMIDT TRIGGER EDGE
>--~.a;)O-T;..;.T-L CLEANUP BUFFER
-
IR LEO LIGHT - SOURCE
f MOTOA DA IVER
(8 DATA -
1 FEEOHOLEt
HOLE. ONE OF
9 1"4 PAPER TAPE
MOTOR
'>N
MOTOR TO DRIVE
PI .. CH ROLLERS TO
PULL TAPE THROUGH
LED - TRANSIST OR
Fig. 4-39: Paper-Tape Reader SE ..SORS
129
MICROPROCESSOR INTERFACING TECHNIQUES
0 0 0
0 0 00 0
0 0 O
0000000000000000000000
0 0
00000 00
0 0 0
0 0 0
000 0
A bit frame for our 8-level tape appears in Fig. 4-40. A typical pro-
blem is caused by the ragged edges of the holes or by dirt on the tape.
The hole data appears in Fig. 4-41 . Due to this, the feedhole sensing
might need some extra delay so that the middle of the feedhole will be
the time at which the other holes are sampled. One must know the
motor speed to do this.
Some systems can go forward and backward so that blocks of data
with errors may be re-read.
The flowchart for this reader appears in Fig. 4-42.
_J
Fig. 4-41: Hole Data
STEPPER MOTOR
Stepper motors are a popular means of implementing motion in
many projects. Each time a stepper motor is actuated it moves its shaft
by a precise angular amount. Popular large angle steppers move by
7.5, 15, 45, and 90 degrees each step. Small angle steppers come in 1.8-
130
INTERFACING THE PERIPHERALS
and 5.0 degree standard step sizes. The advantage of such a discrete
step output is that one always knows where the motor shaft is by coun-
ting how many steps the microcomputer has sent to the motor.
READ A TAPE
TURN ON MOTOR
----
STOP
ERROR
(NO TAPE}
YES
NO
YES
STOP (OK)
The interface to a stepper motor is not trivial and can be much more
complex than the one that appears here. Use imagination to improve
this design, as this one is the least energy efficient but most commonly
used.
The motor itself has four windings: 1, 2, 3, and 4. By applying
pulses of current in the proper sequence, the motor will step. There are
three sequences.
131
MICROPROCESSOR INTERFACING TECHNIQUES
117.7
VAC__3
100 ohms
100WATTS
1000 uF@ 75
VOLT
KICK-BACK
PROTECTION 2
DIODES
4
MOTOR WINDINGS
LSB 10K
AO
A1 10K
PIA
A2 10K
a,.2.3,4=
A3 MOSPOWER
V--FETS.
(SILICONIX)
132
INTERFACING THE PERIPHERALS
3
4
TIMING
Note how in the truth table we are shifting a half byte of two O's and
two l's around and around. The program then becomes quite trivial.
All the programmer has to do is rotate the value 00110011 in an 8-bit
around fashion, outputting it before each rotate to our PIA.
TIME AO A1 A2 A3
a 1 0 0 1
b 1 1 0 0
C 0 1 1 0
d 0 0 1 1
In 6800 code we need to rotate 8 bits. Because the 6800 only rotates
9 bits, we must think about this problem. The solution lies in a simple
programmer's trick. Instead of rotating, one can continually add the
number to itself twice.
133
1-l ~
~
~ ()
;;o
,,
0
g
m
u,
u,
0
;;o
CARD
z
~~?
-i
.-·
~ m
(JC ;;o
...J. SIGNAL
~
ell serial zG)
READER
.,....00 READ data -i
m
,s· DATA ()
~ I
z
~ CONDITIONING
0
=
Q. Reverse Sense C
.,
~
Card Sense
m
u,
MPU
Motor On
WRITE GATES
DATA
WRITE
-·
~
~
HEAD
DATA
;.. SHAPER
WRITE HEAD
n
SQ
a
fg_
..
n>
READ DUAL EDGE z
=
S'
f')
-t
m
,,
;;io
II!:" f)
;=-·
C, z
G)
READ -t
a HEAD
::r:
m
""C
m
~
""C
::r:
..
~
m
~
r-
(.1)
MICROPROCESSOR INTERFACING TECHNIQUES
The only thing we must remember is to add with carry so our byte
will appear to rotate.
LDAA @$CC Load ACC A with 11001100
LOOP STA A @$8000 Output ACC A to Stepper PIA
ADCA Add ACC A to ACC A twice
ACDA
JSR DELAY Delay pulse step time
BRA LOOP Go back and loop again
One of the latest developments in the technology has been the use of
encoded stripes on the backs of charge or bank-cards to carry infor-
mation about the bearer's account. Described here is an interface for
just such a stripe reader. Fig. 4-47 shows the block diagram of the in-
terface.
The program will control the decoding of the information on the
stripe and the movement of the card in the reader. In normal opera-
tion, the card will be sensed at the pressure roller, the drive will be
turned on, and the card will be read. If the data is bad or represents a
forgery, the card will be "eaten" by the reader. If valid, the card will
be returned.
We will assume that the card has been recorded in F2F coding
(" frequency-double frequency"), where each "1" bit is l wo transi-
136
INTERFACING THE PERIPHERALS
tions, and each "O" bit is one transition, per bit cell. Thus, the data
off the head may appear as in Fig. 4-48, second trace down.
RECORDED
DIGITAL
n
__J
n
L_J LJ
n LJ
I
DATA
PLATBACK
HEAD
ONC.R. I SOmv
P-P
OUTPUT OR
COMPARATOR
CON DITIONER
•I
137
t:
QD
3:
150K
n
::0
74LSI25
0
""'ti
DATA ::0
0
lOK n
m
.-·
~ (/)
(/)
(RI ._.OSuf 0
ENABLE
::0
t- WRITE
~
100 220 I.SK z
-j
m
~ ::0
=- "Tl
~
ft)
3 - STATE DRIVERS
=
ft)
so
Q,
+
lK
z
G>
.05uf
..'-·~
-j
J
LM324 m
n
-
f t)
~
::z::
z
D
C
..
ft)
IK m
~ (/)
Q QUAD OP-AMP(½ AS AMPLIFIERS' ½ AS COMPARATORS)
-·
:s
f")
fA l/3V
s
IQ DATA OUT
IK FF
741..SOO
-l/3V R
INTERFACING THE PERIPHERALS
START
NO
BIT IS A I STORE IN
BYTE
BIT IS A ZERO
STORE IN BYTE
NO YES
DONE,
PROCESS BLOCK
139
MICROPROCESSOR INTERFACING TECHNIQUES
Next the hardware for reading and writing on the card is examined.
The write electronics will reverse the current through the write head,
causing the magnetic field to change on the card stripe. Where illus-
trated in Fig. 4-50, the receive or read amplifier is also shown.
The read section detects both the positive and negative going signals
to insure noise-free data recovery. Shown in Fig. 4-49 is the output
waveform.
The read-write software can be aided by using a UART or USART
for converting the data, but the UART in software allows the most
versatility for reading and writing formats. The flowchart for the out-
put data read decode is in Fig. 4-51.
"
1---9 PULSES ~1,. 6 PULSES •I• 6 PULSEs---f
LOGIC
I ___________.,
~ - - -- I BIT ----.cJ
Fig. 4-52: Bit Format for KIM-1 Cassette
140
INTERFACING THE PERIPHERALS
The program will generate these tones by counting loops that will
generate either tone. This will use one output bit from the program-
mable interface and ROM chip on the board. This output bit will be
buffered and filtered to conform to the input specifications of most
tape recorders.
When a tone is sensed, the phase lock loop circuit on the board will
differentiate between a 3700-hertz or 2400-hertz tone. By timing the
duration of the tones, the data bits may be decoded. Fig. 4-53 is the
complete tape recorder interface schematic.
VCC
CON'Jl4-+-------,
AUDIO OUT (LO)
ovcc
AUDIO OUT ( Hll
+12v.
l IN
AUDIO
+llv
1--MA,-_ _ _ _ _ _-ovcc
LM565
141
MICROPROCESSOR INTERFACING TECHNIQUES
142
INTERFACING THE PERIPHERALS
1200 hertz (a "0"). To generate this, only a few flip-flops are required
along with a quad NAND gate. Shown in Fig. 4-55 is the modulator.
+l2V
CD40l 1(3/4)
IOK
EIA DATA
.OS
200
FROM uPUART
TX CLOCK
C
D ,.__ _ _,
The condition of the input data will cause the multiplexer to choose
from either 2400-hertz or 1200-hertz tones. The resistor network is
used to reduce the output to 10 millivolts for the microphone input of
the tape deck.
The demodulator must detect whether the 1200-hertz or 2400-hertz
tones are present. There are many ways of doing this; however a com-
mon one is to detect zero crossings of the input signal. This will gener-
ate either 2400 or 4800 pulses per second. A one-shot is used, tuned so
that if it is not kept triggered at the 4800 rate, it must be the other rate.
The advantage of this method is that one generates the clock needed
by the system's serial UART to untangle the data. This is why, in this
case, the closk to the receiver UART is usually generated by this cir-
cuit rather than the transmitter clock.
The circuit for the demodulator appears in Fig. 4-56. The demodu-
lator timing appears in Fig. 4-57. Note how one gets back what one
started with, along with the necessary synchronizing clock informa-
tion.
If the tape speed varies, the data may still be recovered, as the clock
information will insure the UART receives the proper timing signal.
No special software is needed, as this interface makes the cassette
look like a paper-tape, punch-reader combination to the computer.
TARBELL CASSETTE
The Tarbell cassette format is a cassette S100-compatible system
which records at 187 bytes per second or 1500 bits per second. The
143
MICROPROCESSOR INTERFACING TECHNIQUES
JACK
IK
CD4030
IOMEG ZXDET
DUAL
, - - - - - - - - - - - - - - - + - - - - - - - - 1 EDGE
DET
SOOuS CLOCK & DATA +l:!V
t-e--'Nv-- HZv PNP SI XISTOR -
IK
ONE 300
SHOT
.Olur RS232C OUTPUT
Q
i IK
- 12V
lOuS
+12V
ONE
~ -___,SHOT t-
Q'' -----------t.._./
+SV
144
INTERFACING THE PERIPHERALS
EIAIN
TB OUT
EDG DET
DUi\L DET
ONE SHOT Q
DATi\OUT
CLOCK OUT II
111111 11111111 11111 I I I I I II I I I II II II 11111111 11111 1111 11 111 111 1I
.. ••
ta ' "' OIO•Olt
U Sl ( tt(
HUSfl>o,lf
•10 • . , 1.-..1
..
Vfli T I
"" I
"
, .. ,.. .. cnstHt
' 111•""5"01'1
p:~
m
......,osn
, ""'''
, 111,1filt
tOv., 1111
..~. I
G,( OC ... 'Ot I
"
I
145
MICROPROCESSOR INTERFACING TECHNIQUES
...., ...
..,....,
........
m
- - - - t- -+----c------+-----++-t----i•fw,11((1
---t-<1--+----- ---+-::.~:::..:;.--=,.--++-;--....,.....,~•
(OT
TO c;,v
I NT[llrA"C[
......
""
......
J>-----+-1-+t----ilPlll•!f l>tfltM•T
M(,tp P(ltlllo'!'
_..,T[ OJ.?,.
11(;,f~TO,
------------'--+-
•!l'I'~~
l • L( ~Tf(:T
146
INTERFACING THE PERIPHERALS
CRT DISPLAY INTERFACE
UHF
VHF
~ ..
,
VIDEO
SOUND TRAP
DETECTOR REMOVES
CARRIER VIDEO
AMPLIFIER
IF AMPLIFIER
. FM SOUND
CARRIER
SYNC 4.5MHz
CONNECT SEPARATOR
H
HERE SYNC,..,s"""cA:-:-:N-:-:-:Nl:-;-,NG,....,
SYNCHRO
SOUND
147
MICROPROCESSOR INTERFACING TECHNIQUES
30 Hz
OR 262.5
60 Hz OR
512 LINES
to the other side of the screen, while going down one line. This is
called the "horizontal-fly-back" phase. It is illustrated in Fig. 4-61.
Two types of scan are used, called respectively the direct scan and the
interlaced scan. In the interlaced scheme, the screen is scanned twice.
The second scaning, or field, is made on lines between the previous
ones. 262.5 lines are available in each field. An interlaced scheme
therefore provides 525 lines per frame. In the case of a TV display
connected to a microprocessor, the usual method is not to use inter-
lace, and to use a straight single scan of the screen on 262 lines. The
frame rate is then 60 Hz. Interlaced could be used to provide titles or
to superimpose messages or titles on a TV broadcast. Two synchroni-
zation signals are used to synchronize the motion of the dot across the
screen: the line sync supplies the flyback signal, and the vertical sync
provides the vertical flyback signal to the beginning of the first line.
Some limitations are imposed, which are illustrated in Fig. 4-62. The
horizontal scan is usually longer than the screen size. The amount by
which the dot deflects past the end of the screen is called the screen
overscan. In addition, the message displayed on the screen is shorter
than the screen itself. This is shown as the display time on the illustra-
tion. Whenever the dot reaches the end of the display time, it goes
black. The time from the end of the display time to the line sync is
called the blank time.
VERTICAL
FLYBACK
-
!BLAN.I DISPIAY TIME BLANK
l....,'f_lM_,~::·:1•~:::::::~----~~~::_-_-_-_-__,,~ •
1-l 1-1
SCREEN SCREEN
OVERSCAN Fig. 4-62: TV Blank Time OVERSCAN
149
MICROPROCESSOR INTERFACING TECHNIQUES
Generating Characters
Characters are represented on the screen by a pattern of dots called
a dot matrix. Two standard formats are used to represent characters.
The most frequently used is the 5 x 7 dot matrix. A lesser used system
is the 7 x 9 dot matrix. The advantage of a 7 x 9 dot matrix is a bet-
ter definition of characters, and a more pleasing representation of
lower case letters. However, a 7 x 9 dot matrix requires the use of a
high bandwidth, and, for this reason, is much less used. A 5 x 7 dot
matrix represents each character with 35 dots. It uses 7 rows of 5 dots,
and each character is represented by a sequence of dots and un-dots
(blank dots or rather "black" dots). The representation of characters
is illustrated in Fig. 4-63. Each scan of a TV line will present on the I
I
screen the five dots belonging to all the characters, and so on. At a mi-
nimum, a 5 x 7 dot matrix will require weight lines on the screen,
since one blank line must be used between the characters. In practice,
for good visual presentation, ten lines are used, and sometimes twelve,
to present a line of characters.
6
CHARACTER
ASCII
CODE
ROW ----1-.e A0
----1..-t Al CHARACTER
ADDRESS
----1..-t A GENERATOR
2
ROW CODE
•• • • • • •••
•
•• • • ••
••
••
••• • •• ••
•••• •
•• •• • • •• •
150
INTERFACING THE PERIPHERALS
6 T0 881TS
NEW D ATA
CURSOR
EDITOR LOG IC
151
MICROPROCESSOR INTERFACING TECHNIQUES
r-,
LATCH
ASC II
CHAR
GEN
L_ J
LINE SE LECT
CLOCK EN
The dots coming out of the character generator must now be shifted
out into serial form, to be presented as a video signal to the television.
This is illustrated in Fig. 4-65 . The character generator provides a row
output for each character of the line. The 7-bit ASCII is presented on
the left of the character generator on the illustration, and the three
line-select lines, appearing at the bottom of the character generator,
specify which one of the 7 rows of the dot matrix is being output on
the right. The five dots corresponding to the row contents are then
gated into the shift register, and are being clocked out in serial form to
the video output.
152
INTERFACING THE PERIPHERALS
DOTS
_n
CURSOR
_n J1IB\r
ANALOG VIDEO
HSYNC
7S MIXER
1_f
VSYNC
Typical video interface levels are O to 2.0 volts, .5 to .75 for the
black level, and 1.5 to 2 volts for the white level. This is illustrated in
Fig. 4-67 . The sync signal is referred to as the sync tip. Its_duration is
4. 7 us. It is followed by the black and white dot signals encoded as a
voltage swing between .5 and 2 volts. The timing appears in Fig. 4-68.
On a standard television, white is lOOOJo level, black is 25 to 300Jo, and
sync is OOJo. Typical voltage swing is 2 volts. Standard television line
time is 45 us.
Finally, the composite video output can be connected to the televi-
sion set either directly, at the level of video entry which has been pre-
sented, or through an RF modulator, for connection to the television
antenna. This is illustrated in Fig. 4-69.
153
MICROPROCESSOR INTERFACING TECHNIQUES
TRANSISTOR
INTE RFACF. TV
LEVEL LEVEL
WHITE 1.562 V 3 V
GRAY
(OPTIONAL) V
BLACK 0.5 V
SYNC
0 V +1V
- DISPLAY ON SCREEN -
WHITE
100%
(FLYBACK)
BLACK
SYNC
I
I
I
I
I
I
- 25 to 30%
0
I, 1:J: 1B.3\li!,. 45.7us
I• BLANK I IME
•I
USABLE DISPLAY IIME
LINE TIME
~64us
CHARACT ER
GENERATOR - VIDEO
OUTPUT ~
.
I
-- TV VIDEO ENTRY
RF
MODULATOR TV ANT ENTRY
(RF)
154
INTERFACING THE PERIPHERALS
.-
-
-
.
RAM
OR
. ROM
.
~
' '
DOT
32OR64 COUNTER
COUNTER ¼l0OR 11
Refresh Memory
For simplicity in design, the refresh is usually performed from a de-
dicated memory. However, a microprocessor system equipped with a
DMA can be used to refresh a screen directly. In this case, dual-line
buffers are used during the DMA transfers between the microproces-
sor's memory and the television display. This is illustrated in Fig.
4-71. The DMA will first fill line buffer 1. During this time, line buffer
2, which was presumed to be full, will empty itself into the output
paths, on the right of the illustration. Typically, line buffer 2 will emp-
ty itself during time 2T or more, where T is the time necessary for the
DMA to fill one of the buffers. Whenever line buffer 2 has finished
emptying itself, line buffer 1, which was long-since full, will be
switched on, and will start emptying itself through the multiplexer. As
soon as line buffer 1 is switched on, the DMA will quickly refill line
buffer 2. This dual buffering scheme guarantees continuous system
operation. The only timing requirement is that the DMA be capable of
filling one of the line buffers in less time than it takes the other to
empty itself. Clearly the DMA should do better than this. The OMA
should be capable of loading one of the line buffers much faster than
the other empties itself. Otherwise, the memory and the DMA would
be used almost exclusively for memory refresh, and no program could
execute on the microprocessor itself.
155
MICROPROCESSOR INTERFACING TECHNIQUES
DATA BUS
LINE BUF 1
MUX OUT
LINE BUF 2
156
INTERFACING THE PERIPHERALS
The CRTC provides the logic for cursor control, sync-pulse genera-
tion, and dot-row selection in an external character generator. All pre-
sent CRTs require an external refresh, a ROM character generator,
and the downstream logic which has been described, including essenti-
ally the shift register and video output. The use of such a typical
CRTC is illustrated in Fig. 4-72.
~u
REFRESH BUFFER
RAM
LP
H SHIFT
V REGISTER
157
MICROPROCESSOR INTERFACING TECHNIQUES
R/W RS CS E
R0-4 ROW COUNT TO CHARACTER
DCLK ..---v GENERATOR (ROM)
RESET VSYNC
HSYNC
LPSTP
BLANK
CURSOR D0-7
6845 ' - - - v ' DATA BUS
CRTC
A0-13 __
.._ _, REFRESH ADDRESS
Vss Vee
Fig. 4-73: CRT Chip Pinout
158
MEMORIES I
'Ill..,. ~
.
,o·
,r11,,. 0B0-7 .. ""~
~ MEMR
..-- !OW C/D
-=
,Ii.
MEMW DB0-7
IOR WR
cs RD
&: HRQ
HACK
cs
~._. , ,i, ~ _.7INTR
E
n
8257
OMA --
DRQ 8275
LC0-3 ~~ CHARACTER
.. ~
.. VIDEO
z
-i
m
00
CONTROLLER DACK
CRT
.. GENERATOR ~ " ,
.
HIGH
SPEED -- " IGNAL iQ
"Tl
)>
~ CONTROLLER 128 X] X 9 DOT .
HOI IZONTAL
SYNC n
~
a .. TIMING z
Q
CC0-6 CHAR. CLK AND VI RTICAL
- -i
SYNC ::r:
..,, INTERFACE
IN TENSITY m
"
-y ~
Vmm CONTROLS ,,
iQ
::r:
m
.... ~
r-
~
U'I
MICROPROCESSOR INTERFACING TECHNIQUES
- LDV is "loaded video. n It is the output dot into the external shift
register.
- Blank is the blanking signal.
- Blink is for flashing the cursor or any other symbol on the screen .
5 X 7 / 7x9 . MTX
A3 -
A4 .
SCROLVPAGE . SCROLL AS -- MEMORY
ADDRESS
60HZ/50HZ - RR A6 .
- Al --
WRITE REQUEST WR A8 --
CURSOR I CM0 A9
I
MOTION CMl Al0 -
-
CM2 DLC0 -
CURSOR MOTION
STORAGE
CMS DLCl -
.
- DOT LINE COUNT
DLC2 -
CLOCK
- CP DLC3 -
LOAD VIDEO
RESET - MR LDV -
SHIFT REGISTER
CSR
FLG
- CURSOR FLAG
BLINK BLINK
BLANK - BLANK
AUTO LINE .- Al COMP SYNC --
FEED COMPOSITE SYNC
VERT SYNC -- VERTICAL SYNC
INTELLIGENT CRT
160
INTERFACING THE PERIPHERALS
161
MICROPROCESSOR INTERFACING TECHNIQUES
takes into account all of the other intelligent terminals in an entire net-
work of terminals.
Since a CRT screen can usually hold no more than 24 lines of 80
characters per line, scrolling and paging our information in and out of
the display is also a desired feature. This is not a difficult function, as
with a large amount of memory a controller can usuaUy store any-
where from four to ten pages of typewritten text. An interface could
provide these functions in hardware; however, by the use of software
algorithms, page-handling characteristics of our terminal are im-
proved. Implementation of commands which will move text by any
number of lines in and out of memory and onto the screen will sim-
plify the editing or reading process.
In addition to normal text presentation, adding some form of
limited graphics is simplified. The microprocessor will allow the inter-
faces to implement such functions as graph and display by using,
perhaps, the characters *, - , and +. As an example, one can imagine
the system where the beginning point and ending point of a line are
specified, and the terminal automatically will graph to its best ability
the line joining the two points on the screen. All these features are pre-
sent in one degree or another in the new intelligent terminals being
manufactured. In addition, there are some personal home computing
products,such as the Commodore Business Machines PET computer,
which also show the use of many of these intelligent functions. The
general philosophy is: "Now that I have a microprocessor, how can I
make it work to improve the interfacing function?"
162
INTERFACING THE PERIPHERALS
entered into the screen memory. The small 32 by 4 control ROM deter-
mines whether the character should be displayed, or whether it is for
control i.e. line feed, carriage return, etc.
PT CO Cl C2
,.s
Writing
Control
Address
Buffen
RAM
TV synchro
Display counter Line end v-noralor
Ou1pv1
Bulle«
!l
mm Vee
9
"'1
10
INI a,
2
Oo SYNC
163
MICROPROCESSOR INTERFACING TECHNIQUES
;
~
Hi
..~~
: ..."':
"' {
.:
I:
;I
!
!
I !
164
.INTERFACING THE PERIPHERALS
;:::::;;;:;
•♦, . . . . . . . ...
..
::::::!:::::
;,ml///1//i!
.....,.,...
·:::;Wl
. ...
·:u~ !:!~
"',.. ....
gg
!! :~
..
•11>•·
t••·
::;;
::=:
::n
'!~:.
.. "~'
. ....
..
:!:!
1
'......1111111!/!
►•
.........
,
. .............
.... .............
·••►·• .. ·•·.. ••
''•:"-►♦.-,
.. ,~·····•·,. ..
,.
165
MICROPROCESSOR INTERFACING TECHNIQUES
The CRTC converts the ASCII data via the character ROM into the
proper series of dots for the television. The format for the system is
for European television of 625 lines at 50 frames per second with no
interlace. Timing shown here will modify the circuit to drive a monitor
in the U.S. with 625 lines at 60 frames per second. A regular television
may be used, but an OEM television will operate far better. In addi-
tion, most OEM-terminal TV sections cost much less than a regular
TV, because power supplies and the tuner are not implemented.
The circuit then is a complete terminal with 16 lines of 64 characters
per line. The characters are displayed with a 5 by 7-dot matrix format.
Lower case characters are possible by customizing the ROM.
'
..t••¼••·
.•· ··•
;~'.: s:\fa\~\uff:
. ' -··
.
.• .....!~.
166
INTERFACING THE PERIPHERALS
,,,.~
/
,./ .,,,..-
/ /
I /
I /
, I
/ /
'
Double-Sided
Stepping Motor Head Assembly
Magnetic Heads
,,
d
\l·I
'1
!1
,,
11
'1 /
i!
'I
11
\
/
,.,
, , - ✓//
I, ,,,_,,
I' ,.,
II ,.,,,
11 ,,,,✓
ti/
carriage Way Doubt.Sided
Diskette
167
MICROPROCESSOR INTERFACING TECHNIQUES
168
INTERFACING THE PERIPHERALS
For example, the access times for a regular floppy such as the
SHUGART SASOO are (single density is assumed):
- Track to track: 8 ms
- Average access time: 250 ms
- Settling time: 8 ms
- Head load time: 35 ms
- The rotational speed of the disk is 360 rpm and the recording den-
sity (inside track) is 3200 bpi for single density and 6400 bpi for
double density.
- The track density is 48 tpi and the number of tracks is 77.
Diskette Formatting
169
MICROPROCESSOR INTERFACING TECHNIQUES
PREAMBLE 46 BYTES - - - - - - - - - - - ,
· ADDRESS MARK l BYTE - - - - - - - - -
PREAMBLE 32 BYTES _ _ _ _ _ __
26 SECTIONS - - - - - + - - - -
In a hard format, actual holes are punched on the disk, to mark the
beginning of the new sector. In a soft format, only one hole is punched
to indicate the beginning of every track, but the length of sector on the
track is left up to the designer or the programmer.
170
INTERFACING THE PERIPHERALS
Soft Hard
Per disk: 80.6 Kbytes 72.03 Kbytes
Per track: 2304 bytes 2058 Kbytes
Per sector: 128 bytes 128 bytes
Sectors track: 18 16
The interface signals include commands and data to the drive and
status plus data from the drive to the controller. To the drive:
- step pulses to the head motor + direction
- load head
- read/write
- data + clock information
- reset error bit(s)
171
MICROPROCESSOR INTERFACING TECHNIQUES
To the MPU:
- Interrupt request
- Transmission request
- 8-bit data
172
INTERFACING THE PERIPHERALS
MOVING HEAD
1. Head positioning:
The head is stepped with an incremental stepping motor (typically 3
to 10 ms per step). This implies the necessity of a programmable step
delay in a general purpose formatter controller. Naturally, a line
must specify the direction of the movement. A head settling delay of
8 to 15 ms must also be allowed for vibrations to die out. The head
can then be loaded on the disk (10 ms settle). It is then necessary to
verify proper positioning by reading the track number in the firsl ID
173
MICROPROCESSOR INTERFACING TECHNIQUES
HEAD
~ ; SPRING
+24V
RELAY
2. R/W controls:
Assuming that the device and the data are ready, the write gate is
activated (for a write). The operation is inhibited by a write-
protected diskette.
3. Data transfer:
The transfer must occur at the specified speed. A typical clock is 1
MHz for single density (0.5 MHz for a mini floppy), 2 MHz for dou-
ble density (1 MHz for a mini floppy).
174
INTERFACING THE PERIPHERALS
®~1:::: Holes
8 .00 in.
Spindle
(200mm) Hole
Hoaa5'o•i Write
Protect7
Notch
SA 1041105/124
-i-
□=i--=
Write
Protect
Notch
5.25in. 6'
~
0
(13L3mm) .__ __ _._®_ _ 3.93 in.
Jm)
1- 5.25 in. (133mm) -..I
Fig. 4.84: Comparison: "Floppy" vs "Flippy"
175
MICROPROCESSOR INTERFACING TECHNIQUES
ROTATION
---.
SECTOR (n - 1)
MOVING HEAD
Accessing a Track
The head moves over the disk surface from track to track. It is moved
along a radius of the disk by a stepping motor. In order to access a
track, the following sequence will occur.
l. The drive select must be activated. Usually a disk controller may con-
trol more than 1 unit and will enable the drive select of the
mechanism which is selected for access.
2. The direction select will be set, resulting in a latching of the direction
of the movement of the head. The head will move either towards the
center of the disk or towards its periphery.
3. The write gate goes inactive. During head movement, no writing
should occur.
4. The step line will be pulsed until the desired track is reached. Each
pulse will result in a step of the head over to the next track, in the
direction which has been latched.
176
INTERFACING THE PERIPHERALS
STEP
TRACKOO
NO
ERROR
RETURN
RETURN
TEP IN '-_YE_S_
177
MICROPROCESSOR INTERFACING TECHNIQUES
CORRECT TRACK
SETTLE HEA.D
("LOAD')
NO WAIT FOR
NEXT SECTOR
YES
INITIATE
READ
178
INTERFACING THE PERIPHERALS
SEARCH FOR
ID MARK
NO
ERROR DIAGNOSTIC
SEARCH FOR
DATA MARK
READ 128
BYTES
OUT
179
MICROPROCESSOR INTERFACING TECHNIQUES
The signals required by, or generated by, the SA 400 mini-floppy disk
drive appear in illustration 4-89. Six essential signals are used to com-
municate with the disk drive:
DRIVE
SELECT 2 SA 400
MOTOR ON
DIRECTION SELECT
STEP
WRITE GATE
TRACK 00
INDEX/SECTOR
WRITE PROTECT
WRllE DATA
I I _L
+5V +12V-=-
MOTOR ON
The signal will turn the motor on, or off. When turning the motot
on, 1 second should be allowed after activation. Conversely, the disk
drive should be deactivated after 2 seconds (or 10 revolutions), when-
ever no further commands are issued. This will extend the life of the
drive.
DIRECTION SELECT
This input selects the direction in which the read/write head will b¢
moved. The actual motion will be accomplished by pulsing the step line.
STEP
This moves the head by 1 track position towards the center or away
from it. The movement occurs on the trailing edge of the pulse.
180
INTERFACING THE PERIPHERALS
WRITE GATE
Write is enabled when this line is active. Read is specified when the
line is inactive.
TRACK 00
The signal indicates that the head has reached the outside of the disk,
i.e., its outermost track or track 0. The head will move no further even
if additional step commands are issued.
INDEX/SECTOR
The READY line is true when the diskette has been correctly inserted
and is up to speed.
The INDEX line provides a pulse marking the beginning of sector 0.
A hole is actually punched in the diskette and detected by a photosen-
sitive circuit.
181
MICROPROCESSOR INTERFACING TECHNIQUES
WRITE PROTECT (optional) tells the system that the user has cut
out a notch in the diskette .holder to prevent any accidental writing.
/
/
/ ''
/
I
' 'I
I I
I I
SECTOR 2S ECTOR 26 SECTOR 01 SECTOR 02 SECTOR 03
/
/
''
/
/
''
/
'
ID loATA J
182
INTERFACING THE PERIPHERALS
PHOTO-DARLINGTON XTOR
OUTPUT
INFRA-RED LED
BIAS
iNFORMATION RECORDING
183
MICROPROCESSOR INTERFACING TECHNIQUES
C D C D C D C D
y y y
' ' ' ' '
DATA= 0101 CLOCK= 1111 t CELL N
1
Fig. 4-93: Information Recording
Other recording methods are used to increase bit density. The basic
principle is to eliminate as many "superfluous" clock or data bits as
possible. Typically, MFM = Modified Frequency Modulation, or
M2FM (Modified MFM) are used for double-density diskettes.
MFM has been used on high-performance disk drives such as the
IBM 3330 and 3340.
The rules of MFM are:
1. The data bit still appears in the middle of a bit frame.
2. The clock bit is written at the beginning of the frame only if two
conditions are met:
- No data bit will appear in the current frame
- There was no data bit in the previous frame.
In other words, a clock bit is inserted only if two consecutive frames
would contain "00".
When reading data from the disk, FM must be converted to digital,
with absolute accuracy. In addition, a separate detection is required for
clock and data bits. Special problems may occur with some bit patterns.
This is known as the "bit-shifting" problem, and a PLO (phase-locked
oscillator) is normally used for precise bit detection.
All data on the disk is structured in bytes. Bytes (groups of 8 bits)
must also be synchronized. Tiris function is performed by starting every
block of information with a special marker. When the diskette is first
used, it must be initialized or "formatted" with these markers. Byte
counts are initialized when these ID or data marks are read.
Finally, a serial-to-parallel conversion must be performed to assem-
ble 8 bits into a byte. This is done by the disk controller.
The operations required by a "write" are naturally the reverse of
those described above for a "read."
184
INTERFACING THE PERIPHERALS
CLAMP WRITE
t
OSCILLATOR
WINDOW DELAY
GEN LINE
SEPARATED CLOCK
SEPARATED DATA SEPARA-
TOR
185
MICROPROCESSOR INTERFACING TECHNIQUES
Applying Power
Updating a Sector
Once a diskette has been formatted, only the ID gap, data field, and
first byte, or data gap, are altered.
186
INTERFACING THE PERIPHERALS
DISK
TERMINAL
DISK
OR
ROCESSOR CONTROLLER
l
PARALLEL OR
SERIAL INTERFACE
DRIVE
RECORDED BIT
1 1 0
187
MICROPROCESSOR INTERFACING TECHNIQUES
Disk Formatting
Both clock and data information are encoded into the same signal.
Clock pulses are issued for every bit. A "O" data is indicated by no
further pulse during the bit cell time. This is illustrated in Fig. 4-97: A
''I'' is indicated by a data pulse occurring in the middle of the bit cell
interval.
INDEX PULSE
TRACK I, UNIIDQUE
--------R-ECO_R_o_ _ _ _ _ GAP
I UNIQUE
_,_o__. . ◊_r_He_R_Re_co_R_o(_s,_ _,
Soft sectoring refers to the fact that the division of the disk or track in-
to sectors is performed by software. This is opposed to hard sectoring,
where the beginning of each sector is physically delineated by a hole
punched in the disk. In soft sectoring, each track is started by a physi-
cal index pulse, corresponding to the detection of the index hole on the
disk. Every record is preceded by a unique identifier. See Fig. 4-98.
Successive records are separated by gaps. Gaps are necessary in order
to upgrade information without erasing the following or the preceding
record. Because of minor speed variations in the disk-drive motor,
whenever a record has all or part of its contents rewritten, the end of
the record might extend beyond the previous record end.
DATA CLOCK
188
INTERFACING THE PERIPHERALS
r ~ l
DATA FIELD
RECORD 1 (131 102
(18)
GAP 34 NC
GAP3:
I I FF
2
FF
17
I I 00
18 21 (BYTES)
129
GAP SYNC
GAP2: FF 00
6 7 10
CRC CRC
ID 1:
1 2
2 3 4 5
GAP 1:
GAP §YNC
I FF
16
I17
00
20
I
For this reason, a blank gap must be provided between the end of
one record and the beginning of the next one. In fact, a gap must be
provided between any two zones which might be updated separately.
Most often, the IBM disk-track format is used, sometimes with minor
variations. This format is illustrated in Fig. 4-100. Four kinds of gaps
are used:
Gap 4 is used only once on the track. It is free-index gap. It appears
at the end of the track just before the index hole position.
Gap 1 is called the index gap and is used at the beginning of every
track. It contains 20 bytes: the first 16 bytes contain the hexadecimal
pattern "FF" followed by 4 bytes containing "00". These four bytes
of O's are the classic way of providing the synchronization for the data
separator. The length of gap 1 may never vary in length. The index
gap is followed by the identification of the first record.
189
MICROPROCESSOR INTERFACING TECHNIQUES
CLOCK
DATA
-----L-ff---
2us
4us
WRITE SIGNAL
Ls--r.-J----i____r-
200us
READ BACK
I 1.8 to 2.4us l I
I I I
I 3.4 to 4.6us I
I I
Hard-sectoring
When using hard sectoring, a special diskette and drive are used . A
hole is punched at the beginning of every sector on the disk. Each sec-
190
INTERFACING THE PERIPHERALS
tor is then started by a physical sector pulse. In the case of the mini
floppy disk, two configurations are used: 16 sectors of 128 bytes or 10
sectors of 256 bytes per track. The track is started by the index pulse.
This is illustrated in Fig. 4-102.
191
MICROPROCESSOR INTERFACING TECHNIQUES
one more step in its previous direction, then moved back. Usually
this corrects most reading errors. If this procedure fails, we have a
hard error.
2. Hard: Whenever usual correction procedures fail to read data from
the disk, it must be deemed unrecoverable. This is a fatal error.
Data is lost.
SEEK ERROR
This corresponds to the case in which the head does not reach the
correct track. This can be verified by reading the ID field at the begin-
ning of the track. It contains the track address. Whenever an error is
detected, the track counter of the disk drive must be recalibrated. The
head is moved back to track 00 and a new seek order is issued.
DETECTING ERRORS
Universally, the error detection for any data written on a disk is
accomplished by using a checksum method. Cyclic-redundance-check
(CRC) is used for this purpose. Each field is terminated with two CRC
bytes. The data bits are divided by a generator polynomial G(X) such
as G(X) = X 16 + X 12 + X 3 + 1. The remainder of this division is
called the CRC. It is written in the two bytes that follow the data.
When reading back data from the diskette, everything is read, in-
cluding data in the CRC bytes. If the remainder of the division by the
G(X) polynomial is not 0, an error has been detected .
Single-chip CRCs exist, such as the Fairchild 9401 and the Motorola
8501, that will detect such failures in a single chip. One-chip floppy
disk controllers (FDC) also accomplish the CRC generation and
checking, within the single chip.
192
INTERFACING THE PERIPHERALS
X6 + Bs xs + B4 X 4 + BJ X 3 + B2 X 2 + B1 X 1 + Bo X 0 •
X is called here a dummy variable.
193
MICROPROCESSOR INTERFACING TECHNIQUES
DATA
INPUT
D a.___._ _
ff
" FF
" FF
" "
0 0 ,.___.__...._ CAC
t:LV<.:K--j-----+--------<I>------+------- - - - - --'
194
INTERFACING THE PERIPHERALS
---- ~ <
0
•
•
•
:
!!;
I- "
u..
i:
"'"
0
a:
u
..><"
♦
"'u
<(
"'0w
w
a:
<
3
..
~
♦
0
a:
...w <
:c
t;;
<II
"g
w
a: u
195
MICROPROCESSOR INTERFACING TECHNIQUES
The previous three commands will read or write data between the
host processor and the disk buffer, or between the buffer and the disk.
- WRITE - DDL: accomplishes the same as the WRITE command
but with deleted data AM (address mark)
- FORMAT: writes address marks, gaps, data on the entire track
in 3740 format
196
INTERFACING THE PERIPHERALS
197
MICROPROCESSOR INTERFACING TECHNIQUES
SA 4400
Controller
l Ftoppy • 80,6 Kbytes
Data, Command, Statvs DISK DRIVE'
(SI Status
Busy
XIP.r
~oc
SYSTEM
FDC On
Command
Acknowledge
Halt
Reset
The signals used by the 4400 interface to communicate with the host
microprocessor system appear in illustration 4-107. The basic se-
quence of events implemented by the controller is simply:
1. Seek track.
2. Find sector.
3. Shift and transfer the desired number of sectors.
4. Check the CRC.
198
DATA OUT
~FFER
I
.-·
~
~
~
~• ~
r~~ DATA
REGISTER
II COMMAND
REGISTER
I rl SECTOR
REGISTER 1-rl I TRACK
REGISTER
~
-
I STATUS
REGISTER
i..
~
t:,
n H
i
1◄ r I 1 •tI DATA
SEPARATOR
n
OATASHIFT
REGISTER I I I
..-
2LALul
::r WRITE
"Cl DATA
WG z
~ (TO DISC) DRQ
TG43
~
m
-="'
~
~
I OE~OR I INTRQ
MR
cs DISK
WJ5
IPRT
TROO
.,,
:;c
)>
()
COMPUTER z
-·-·-
t:,
~ RE INTERFACE
PLA
CONTROL INTERFACE
READY
PH\/STPP G)
'°
MICROPROCESSOR INTERFACING TECHNIQUES
The alert reader will notice that all of the above features are essen-
tially standard for all FDCs. The differences are usually the level of
the number of disk drives that one chip will control simultaneously.
The internal architecture of the FD 1771 B appears in illustration
4-108. It will be described in detail now. It containsfiveessential func-
tional circuits, six registers, and two interfaces: a processor interface
and a floppy disk interface. Each will now be examined.
200
INTERFACING THE PERIPHERALS
u. ..JOQ..CL ►
l-
o
:r .......
(/) u.Q
-w
LU._, u,
~ ::,
a l
...._ I
'
. • l r
' •
5 ·~
:!: ·~
,~ ,~
....... SI
~c -
.._,
00 r-t .......
N
::c
1SI
<
.....
< I~ lli! :c
N
.._,
~
~ C!I :::,,,!
:::,,,! C, .,_
a::: _..J
u
.... ,.
SI a:: :::
r-t A
r
U02::CL::>t-Wa: -zt-wa:u.<uw
201
MICROPROCESSOR INTERFACING TECHNIQUES
1. The data shift register assembles 8 bits from the floppy disk data,
or serializes 8 bits received from the microprocessor data bus into
the floppy disk data line.
2. The data register is a simple holding register for a byte during read
and write operations. It communicates with the data-out buffer,
and may receive data directly from the microprocessor data bus.
4. The sector register holds the address of the desired sector position.
5. The track register holds the track number of the current head pos-
ition. It is incremented towards the inside (up to track 76 on the
regular-size disk), and decremented otherwise.
6. The status register simply holds the status information of the con-
troller.
Processor Inter/ace
The processor interface and the floppy disk interface are illustrated
in Fig. 4-109. The FDC communicates with the processor via 8 bi-
directional data lines labelled DAL (Data-Access-Lines). An input is
202
INTERFACING THE PERIPHERALS
Al AO RE WE
203
MICROPROCESSOR INTERFACING TECHNIQUES
Summary
204
INTERFACING THE PERIPHERALS
OTDATA
DATA(8) ) JNnA.TA
ENCODE'
A(l _ INSTR DECOD,
Al AMJN
cs Ul:o,1K
AM
RE FLOPPY A.MOT DISK
DETECT/
WE DISK GEN
MR CONTROL- WG
MPV +SV LER WPRT
DRIVE
FORMAT· - WF
TER IP
•►
18K :~ • 18K TRf6~
FD1781 -
DRU READY
JNTRO TG43
CLK STEP -
DIRC -
-PEN_ HLDl
- -
ONE
- ~ SHOT
l Yss VooVcc
q II
II +12 +5
(IF USED)
20S
MICROPROCESSOR INTERFACING TECHNIQUES
The PerSci Controller uses the WD 1771 and an 8080 to perform the
intelligent floppy disk control functions. The board contains the data
separator PLO, the 1771 interface chip, a lK static RAM buffer, 4K
ROM memory, 8080 CPU, and miscellaneous circuitry.
Physically, the system consists of one small printed circuit board. In
order to adapt the controller to the S100 bus, a "piggy back" arrange-
ment can be made by placing this controller on a standard S 100 bus
board. The data are recorded in the standard IBM format and up to 4
drives may be accommodated.
0
BUGV 0
X~~ l) ~lJCON Cl.
1)1\l ,\ PC 11l ! lJ'; lH 1\•N 1T [
NC, .,,.---------....
HAi, I ~.15 l L AP"iE: 0)
YES
NO .,,.----"-------..,.
CURRENT DR IVE'
YES
SET Oftl\lE OESELECT FLAO SEl SETHE WAIT FLAG
YES
TO COMMAND
DECODING
206
INTERFACING THE PERIPHERALS
POWER ON RESET
.....--_.:i:!:4 ====:;---.. .o
SE J STATUS PORT ALL ONES
CLEAR H ISTORY ANO
CONTEXT
NO
YES
SET 1NlTIAll2'ED FLA(.;
IN I TIATE SH K l'OZE.ROBY
STEPPING ONE TRACI<..
SET SEEK I~ PROGRESS ANO
OAIVE R EAOY FLAG
8
ro MA lf\j
POLLING tlloP
207
MICROPROCESSOR INTERFACING TECHNIQUES
.. .
~· '
-=.,, ' -__~
-·
~~
~-•!.
.."
.._11 S7
WI -,• •
' ."!· ii~,;,•
Ml 111 - W
U2~
&080• ...' i
"27A
,--i
.
MSl,'i 4
~
1~ • Jl'i
..]J!la
I --ffi
·-11
..~
i---
~.
D I
I l)f '
I
I, -
,--
r-
II
I II ,-
r--
'
J
-
t-
208
INTERFACING THE PERIPHERALS
HIGH IS Tl)UE
•O •
bt=============±!M~: .1 ol01
H L..+---_._." C~~,Dfo/
. .,.__.....__ __,_ _ __,~:. ~'J~ T .......-"T"---:PE:-RSc=-1-,.,.,N-C-.- - ~
SCHEMATIC
DISKETTE ~ CONTROLLER-2
--·.
M00£L 1)70 ?:,'; 200351 A
209
MICROPROCESSOR INTERFACING TECHNIQUES
""' ...
...,.. ....
..... ,
...,....., ."'"'..
.,.,...
..
Al
...... ...."
uP0-.59 PROM } uPD2101AL- 4 uP02 t0 1AL· 4
r-llO]J#:.:~
N · Af
wP02l08 ROM
11< BYTES RAM 2 5 6 BYTES RA~
M• f,•
N• .U'
M•.1•
..,
· -AIO
- ----
··••
- · - · - "1
0: · - - M,
...u
0 ·- 11'!1
~.
"'z ·~ -·- •2
,,
· · - -A"
8 - · · - 1 ,J
-·~ .
RI
""""I .
I
__
- -~
..,......
- - - C, _.£101f
I I - c-:-Tnnt
c
•------- - - =
-
"' I
.1 ,I
...ffit,
I
I
I
__..,
:~t=~--~~:;~_-_._-:.:.-===·--=:!
__,.,
i: I""> ••n ...... . - OH
· - - - 082
0
N-Wlilili
1 1,12J ~,n
~
oeotPt.~~-:--11-iiii"t,.."T" "· --=~:~
~
H-illiil'~ ii=Jil!Vli
ll'Wllr---
1r-t11111. - -H-=R,111
- """'
I
N~Olf!-- - -- - -- - -G:J
• ·OM!-- - - -- -- -€)
•--1-- - -- - -- -ut
..... ~,-- - -- - - - -{a':::
II
I
1
1t-oa1;.- -- -- - - - - {'i]_
210
INTERFACING THE PERIPHERALS
'"'
DB7
r Rf;Q
----
...llrvirr'ffiml
Of:"
D. . ll!imTillli
...
KOH,
00, fffp
••• '! g8e!
.~
tiliOLoiD
n :;
'"'
..
~
~
~
, n 081
., Wii.lU GATE
,,
••• ••• a:
Cf7oi • u •l:!:V 1::
74365
U13
.to GJrt0
.,
•OV
.,..,,
""
IWA,TE OATA ..,
<J
"'"'
0
(.}
~ U 14 1'a,:':l
f:'iNT'i uPD372D lj
UPI
I"'
·~
UP2
u•s I~
-... ,o
•sz
" UP4
UP< Ul5
Al
""' ,,.,cue
,~
U P7 11[1 "l[T,ro,I•
Ql l:n'TLI
NO '16C:11 11STA 10
Puu. UP
SOURCES
.. WFf
1
"" ~
12i
....
I
cTtow ,."'" . ...
u o•
""
,...
1ifiD'i I
"' I
~
c-iH'fl.
c:T7ow
) OS
.,. HIX
1
,.
"' .. Tiiicii""ii
INO(II I
I
..
c-11111TA
tt[SET
.,
UP2 UP2
...
41 •1
A'tSEf
..
•CK
•2 I TTLI
,
UPI :5V
UP2 UP2
'" CNIP llSl
Z DZI Ol.&l.--4
1400 '°"
7404
1401
741,
mo
702
• 1474
• 7412'
....
!, 74 125
~"' l 7'4 1'7
l TN[ ..O~T , . o C[S\0 111 1,1'!0 C()OIIU IOLl f .. P ~O-C(SSOA .Ill( ~YN ,,..oao, o•·s
H01,J PAOC[SS.OA
$1(,t.l.l L~••r.-s s,~.....
,111( r , l [C
l'!. ...[ Ht[•IMtU
*''"C· .
• ·n, ... (0,,,T'l,o,.L(" HIOtl:UOllt
6 JtS• • ltS I ¥ UST e [
EDG( ~
St.Al t ( f"llt Qlf 1,0111 N:FQ,tf 1 0 10.. .Arf(A TH[ TIIIAIL11fG
II !SU ~111)3,J"t Slll(" ICATIOIIISI
C MIING(S w,r .. THf: t [AO•N~ [0-[i[ 0# e:t.
,n u:n S"l"N("ltO,.,. tJ(S •s•,111s1
,
TM[ "OST .. 01lllC T 1111[ ""-0A T &tens llfT(;' '"'[ COlrtTlll'A.l[ll-""0 ' VIC£ ',( As.I , t U'NLUS OYHfQI SE Sll(Clf"l[I) Au. lll[ !l-1'.llOAS 11••. ! S'!I.
..on AOOll[SS o,
SICOll!L'!. DO ... 11( .l(M TNl COJIITltOl.LHI llll[ MOill1($ u,.,,..._ 2 -~,,
C· NLOA IS Gllt• •nto Oulll•lf,. NO'.ll • ccc ~~- TM{ ltOST ,s TM[" "'' ... TW
\ Ta rt o ..t SHOT U2U ,Cl;( P5 n,[ M-lt(AC,T LIit[ tO-W 11'0 .... ,,.u,,. A0)A[S$ l #N224
&HO o,i,r& P&JHSl ro11 .., LU,U ' " ' 4~').., ..[ ...OA'T ,t(([5S T IM[ .
,_.
4 li"'"ft IS t.t • t • o, lllt[${ 11fl :>Ultl NG 4 · "IT( (\'Ct ( WH{,. Toe[ ..OST IIDQIESS
Sl ~llt5- 11[.t,(.oc TH[ (OfltTltOL~, · M[ MOA,u 1i..os1 ,s ,,. A.,.. STAl( ..., c -..LOA l \ HO:t:
, .., 1 O[LAY C I IICUIT 11.(CIIS r ..f .CO..TROu.c • ........, . s,c;.,.,.lHl(.H ' ~
fw[ 11(01,1111(1) , _ ' '""( SH ~"1>1 1().l&L t"(( 1f" 1(,\l1 0t,I RHISTO"
~ Tltd t1•cu,t JIii$ All, ..... jN[II") t OOt 111: NA&~l IN f [IIIIJl'f l o ... ,o TN(
0 A1 f< 9U$ OVll1ti1G C - 1r.T111 SPftAiout NO.
4Cl )JX$TR
5' OTAL
211
MICROPROCESSOR INTERFACING TECHNIQUES
SECTION V: NEC FLOPPY DISK CONTROLLER
The NEC FDC is called the UPD372D. It is compatible with the
IBM 3740 as well as the SHUGART mini floppy. It provides the usual
facilities, such as CRC generation, programmable step pulse, track-
stepping rate, sector size, data-transfer rate. In addition, it controls up
to 4 disk drives, but with read/write limited to one drive, with
simultaneous track seek on the others.
Other disk drives are: CAL COMP 140, CDC BR 803, GSI 050 and
110, INNOVEX 210, ORBIS 74, PERSCI 75, PERTEC FD400, POT-
TER DD4740, SYCOR 145.
TO
RES(T RST WO I$ WRITE OATA ) DISK ORIVE
19
KLD HEAD LOAD
REGISTER
SELECT
r«•m ~""~" "'"'
REGISTER DAU STROBE
REGISTER SELECT 2
2
'
4
"'"'
OS
•s2
LCT
WFR
W[
22
l3
24
lOW CURRENT
•A I TE CURRENT ENABLE
COMMA"IDS s 25
REG I STER SELECT l RSI sos STEP OUT OR 5T£P DISK DRIVE
REG I STER SELEC r e • RSe SlD
26
STEP IN OR DUIECTIOJrtil
COMMA"IDS
27
U8 1 01S1< ORIV( ll S£L[CT
UH
,. DISK ORIV[ ee S[c£CT
17 29
lHT£AAUPT REOV(ST REO UAI OISK OA IV( Al SELECT
)0
u•• 0 1$K ORtVE Ae SEL ECT
31
OATA eus • 08D
DATA BUS l
DATA 8uS Z
..
32
,.
DBI
082
RCK
RO
10
"
READ CLOC.C
AEAO DATA
} FROM
OISK DRIVE
}""
31 ii
OATA 8\JS 6
DA.TA aus 1
,. 086
087
WFT
ree
,. #RtT£ fAUlT
TRACK ZERO
STATUS
RYA
12
OISK DR1\1'£ A A[AOY ~'"
14
RYB DfSM DftlV E 8 AEAOY
.,
13
we<
"··~{
WRIT( CLOCK
., fll c•s
15
CLOCK ST.& TVS
}MISC.
42 t6
112 92 AWL ALWAYS LOW
vss
20
...
21
vcc
39
YOO
40
212
INTERFACING THE PERIPHERALS
I 1 1 II 1 11 ----sn• (sTP)
1111111D 1
, I REHT (> IR)
D0 ERROR STATUS-R GENERAL COUNT- W
•• IIl l Il II I I l I I l 1
HEAD DIRECTION (HOR)
HEAD LOAD ( HLD)
D7
• SECTOR ADORESS-W INTERRUPT STATUS-R WRITE GATE .!wGT)
111111 [IlJJ LOW CURRENT ( LCT)
~Q
RE.El SEARCH TRACK ADDRESS CRC CONTROL- •
CLOCK r 1111111 [[I
WR !TE DATA (WOT)
DATA CLOCK (OCKl
BUS DIREcpoN ~-READ ONLY REGISTER READ DATA (ROT)
DMA END (oMf~) W-WR ITE ONLY REG I STER VFO CONTROL (\/FCC)
R/W-READ/WRITE REr.JSTER
OMA R~~~m +EV
DMA .lCKNOlfLEDGf GND
(OMAK)
213
MICROPROCESSOR INTERFACING TECHNIQUES
FDC REGISTERS
DORREC EQU $DFF0 W10 WRITE TO FLOPPY
DIRREQ EQU $DFF0 RIO READ FROM FLOPPY
CTAREQ EQU $DFF1 RIW CURRENT TRACK
CMRREQEQU $DFF2 W10 MACRO COMND & IRQ
MASK STRB MASK; WRT CLK
CNTRL; OMA ENABLE
214
INTERFACING THE PERIPHERALS
TO COMPARE TO ID FLD ON
OSK
FDSELI EQU $DFF8 FL DSK SELECT ADD
215
MICROPROCESSOR INTERFACING TECHNIQUES
ORG $0000
DATA BUFFER FOR READ DATA
ORG $100
PROGRAM AND FLOPPY DISK INITIALIZE
216
INTERFACING THE PERIPHERALS
ORG $0400
SUBROUTINE TO REMOVE DATA TRANSFER
ERRORS OF PREVIOUS OPERATION FROM REGISTERS
217
-
N
QC
n
~
;;o
0
""O
;;o
0
n
m
en
en
0
;;o
PPS-8 R/W
~
FDC
z
.....
.
/JC•
DISK I
m
;;o
...
....
I CONTROL I _____ '
A
►
n
~
..
~
STATUS z
G)
-=00-=
.....
GPI/0 m
()
HEAD POSIT :::r:
d
(:l
OR
PDC
DRIVE I z
D
DISK UNIT SELECT (A ORB)
CONTROL I C
m
en
DRIVE
CONTROL
DISKB
.-·
lo'!j
(JC
l'fN
DMAC
,I.. F0 I I
~
I FORMAT
..
N
CONTROL
H CHANNEL 7
,I.. I
~ BLOCK REFERSH
~
r.,:i
• (16-BYTES/lllM) I
00
lo'!j
0
100 I II CHANNEL 1
II -I F DC
n
0
~ I I I I I
I CHANNEL 2
I
> 30A
DATA z
~
n m
-=
;it:,
BLOCK "Tl
)>
0
~ <128 BYTES) ()
:,;- z
G')
-·
0
=
IJCl
;
-I
:I:
m
FDC REQUIRES 2 PATHS: FORMAT CONTROL AND DATA.
:I ""O
m
;it:,
"'ti
:I:
m
;it:,
)>
....
N
\C
U)
MICROPROCESSOR INTERFACING TECHNIQUES
0 1 s s 0 0 0 0 NOOP
0 1 s s 0 0 0 1 START
0 1 s s 0 0 1 0 LOAD
0 l s s 0 0 l l CLEAR
0 l s s l 0 l 0 READ DATA
0 l s s 1 l 0 0 READ STATUS
0 1 s s 1 1 0 1 READ STATUS
0 1· s s 0 1 0 0 NOOP
0 1 s s 1 1 1 0 NOOP
0 1 s s 1 0 0 - UNDEFINED READ
0 0 0 0 1 0 0 0 READ INTERRUPT STATUS
I
220
INTERFACING THE PERIPHERALS
I
POWER ON
CONTROL
HEAD MOVED
TO TRACK J
REGISTERS
I
NEW FDC
COMMAND
INITIALIZED FOC
GENERATED
INTERRUPT I
ENTER FROM
DMA BLOCK
FORMAT
I
I
CPU STORES
REGISTERS
STANDARD
PPS-8CPU
INTWUPT
I
Rt)lART
IN STACI< SEIVICE
ROUTINE I
FROM
"RETRY" I
I
PROCE S
APPLICATION
UNTIL
INTERRUPT
I TO CPU
INTERRUPT
I SERVICE
ROUTINE
I
I
I
I
L __ _
221
MICROPROCESSOR INTERFACING TECHNIQUES
222
INTERFACING THE PERIPHERALS
0
-I
0...
v,O'W
::>~u
coz<(
_u..
°'....w
::>
0...
~
8
Fig. 4-128: An Intelligent Floppy Controller
223
MICROPROCESSOR INTERFACING TECHNIQUES
Intelligent FDC
An "intelligent FDC" is intended to make the disk transparent to
the user. The facilities of an "intelligent" floppy disk controller can
include:
- symbolic file naming (requires a Disk Operating System)
- automatic space allocation on the diskette (requires a File Man-
agement System)
- file header management with date of creation, date last modified
- index track management
- file editing
- input-output buffering
- various optional interfaces (RS232, SWO, 8-bit parallel)
- diskette format initialization (gaps, marks, ID fields, data fields)
- sector interleave
- file directory management
- space reclamation ("garbage collection")
- various access methods: sequential, random, direct, stream
- renaming/deletion of names
- file copying
- error detection and auto-retry on soft errors
- diagnostics
- code specification
- write ASCII, Hex, deleted data
- read ASCII, Hex
- display buffer
- enter into buffer.
224
INTERFACING THE PERIPHERALS
1- DIRECT TRANSFER
HOST FDC
2- BUFFERED TRANSFER
RAM
HOST FDC
BUFFER
225
MICROPROCESSOR INTERFACING TECHNIQUES
Storage Management
Files are usually granted contiguous sectors so that they can be read
or written at full disk speed. However, when a file is deleted, the de-
allocation process will leave gaps on the disk. Unused gaps waste
storage by fragmenting it. Periodically, or whenever a storage request
cannot be granted, it becomes necessary to compact the gaps,: The pro-
cess is known as "garbage collection," or compaction.
1. Sequential, or stream
The complete file is stored/accessed continuously. This implies the
use of contiguous sectors. The method is simple and efficient if all
the data need be stored/accessed.
2. Variable length. or punctuated
A file is handled as a sequence of variable-length records. Used
when portions of a file will be modified.
3. Random access or relative
Any byte (or number of bytes) may be read/written, even across
sector boundaries.
226
INTERFACING THE PERIPHERALS
4. Direct access
Any sector on any track may be directly specified, bypassing the
File Management System.
The DCO
227
MICROPROCESSOR INTERFACING TECHNIQUES
. . - - - - FOURTH ELEMENT
- - - - THIRD ELEMENT
- - - SECOND ELEMENT
- - - FIRST ELEMENT
fout = OSC/N
Note that N can only have integer values. This limits the accuracy with
which a certain frequency can be approximated. An analysis was per-
formed to determine if 12 bits provided enough accuracy for the music
synthesis. For a 5 MHz oscillator, it was found that for a 4-octave
range, the maximum possible error is 2.25 cent. where a cent is 1/100
of the logarithmic distance between any 2 adjacent notes (half step).
228
INTERFACING THE PERIPHERALS
This is quite acceptable. Consequently, this 12-bit DCO was used for
generating the basic frequencies of this synthesizer.
CARRY
OUTPUT
COUNT-
LOAD
ER
4 BIT
12 BITS FROM
OUNT-
MICROPROCESSOR
ER
4 BIT
COUNT-
ER LOAD
DCO
osc
229
MICROPROCESSOR INTERFACING TECHNIQUES
Using the first four members of this basis, any wave form can be
approximated, though its error may be large. After examining the
wave forms of a harpsichord and piano, it was decided that the easiest
approximations for these would be that of a sawtooth wave and a
distorted square wave.
+SY.
22K
22K
FROM
HARMONIC
GENERATOR
OUTPUT
22K
22K
VOICE CIRCUITS
OUTPUT
120K
22K
The outputs of the harmonic generator were not suitable for mixing
directly to produce these wave forms, since the output levels varied
anywhere from 2.2 volts to 3.8 volts. Thus, these outputs were buf-
fered using CMOS since the CMOS logic family's output levels differ
from that of the supply voltages by only several millivolts. The
unusual element that appears in the resistor ladder is a member of the
CMOS logic family, called a bilateral analogue switch. When its input
control voltage is high, the analogue switch appears to be a 200-ohm
resistor for all voltages bracketed by the supply voltages. When the in-
put control voltage is low, the analogue switch appears to be a 200
Meg-ohm resistor. This analogue switch is used to select one of the
two voices.
230
INTERFACING THE PERIPHERALS
Articulator
Another factor which colors the characteristic of a particular
musical instrument is the rate of decay of the sound. For example,
when a key of a harpsichord is depressed, a string is plucked and its
loudness quickly dies out. Whereas with a piano, if the key is held
down, the loudness of the note dies out very slowly. But by releasing
the key, the note is quenched. The equivalent of these functions is
accomplished in this synthesizer by the articulation circuit, or ar-
ticulator.
MULTIPLEXER
->-----,-----•Vour
3.3K
VcoNTROL
IN914 TO
MULTIPLIER
~ - - - - • CONTROL
STACCATO I
CONTROLS
FROM
,......_IV\r-,o+SV
MICRO
!OK
1.8K 2M
2N2219
Tempo Generator
~----------0 Q
200K
0.47uF
2M
82K
232
+SV
0 0
-·
~
~
,I:;..
-·
~
~
,I:;..
w
8
;;,,:
....
I
!:60i
....
I
......
~
co
IS
~ <}--J
~
~
0
~
74161
e -
b
C:
=
I 'Cl ~
,o
~ T£M~
C z--i
::s 0 m
=-
n 5601< 22K
::s
1
,c
'"T1
~- I '
"•• ; Q >5V 00
:r
)>
n
--·
= -
C z
G)
--i
:I:
m
Cfl.RK
t'"' w
3::
v.i
"'O
m
,c
"'O
:I:
m
~
N
~
fi;
~
MICROPROCESSOR INTERFACING TECHNIQUES
The Software
"'<
~
u
234
INTERFACING THE PERIPHERALS
SET NOTE
TO REST
NO
235
MICROPROCESSOR INTERFACING TECHNIQUES
236
INTERFACING THE PERIPHERALS
When the retrieved code word specifies a rest, the Main Program
places the number 409510 into the DCO memory cells. This would be
interpreted by the DCO as asking for infinite frequency. However,
because of the idiosyncrasies of the DCO, this number will cause the
DCO to stop oscillating. The Main Program then calls the Rest sub-
routine, which clears the Gate Sounding bit of the voice control
memory cell.
FETCH NEXT
CODEWORD
STORE IN
VOICE
CLEAR THE
GATE SENDING
Before discussing the Note Decoder and Note Scaler subroutines, let
us review the DCO. Recall that the output frequency of the DCO is
given by:
237
MICROPROCESSOR INTERFACING TECHNIQUES
DOA 12BIT2'S
· COMPLEMENT
DIVIDE BY
2
SEENOITIN
MEMORY
CELL
After both channels, or hands, have been deciphered, the Main Pro-
gram calls the Sync subroutine, which waits for the tempo-generator
pulse. This pulse signals the software that it's time to send the next
group of information to the music synthesizer hardware. The Main
Program then calls the Send subroutine, which sends the contents of
238
INTERFACING THE PERIPHERALS
NO
NO N~:1t"s\ Nc
.,
PULSF COME
START SEND
UBROUT INE
RETRIEVE THE
NOTE MEMORY
CELL AND VOICE
MEMORY CELL
DETERMINE
WHICH CHANNEL
GETS T!IIS
INrORMATION
SEND INFORMA -
TION TO APPRO-
PRIATE OUTPU T
PORT
the DCO memory cells and the voice control memory cell to the cor-
rect channel. This is done for each channel. Lastly, the main program
calls the Refresh subroutine, which resets the Gate Sounding bit in the
voice control memory cell, and then returns to the beginning of the
program for the next cycle.
239
MICROPROCESSOR INTERFACING TECHNIQUES
For each note, the desired range, voice, and articulation changes,
when applicable, are specified first, followed by the note, rest or
system-command code. If there are no changes in the range or voice or
articulation,then this field is deleted.
The two pages following those contain the coded music for the
First Two Part Inventions by J .S. Bach.
The system commands are treated in the same way as notes, for they
can only result in small changes in the previous note played. The com-
mands are to continue playing the same note, play the same note
again, and stop playing for the composition is finished. The command
for continue playing the same note means that the note should remain
audible, but should not be ''struck'' again. This is accomplished by
clearing the Gate Sounding bit in the voice control memory cell. The
command to play the same note again means that nothing at all should
be changed; the note should be exactly like the previous note.
240
Inventio 1 J. S. Bach
"'!j
Coded music for Right Hand
(iQ.
. 9.00.,FF 09 BD 1 1 2D 0B Dl 1D 09 DI 4F 49 F-4 8F 49 F4
-..
~
~
~
~
I
9~10.1B4 68 96 84
9·;20., 1D 13 9D 21
9~30~6F 4D 0B F4
BF
D1
Dl
4D
BD
9F
24
22
4F
F4
JD
4B
2F 44 FLJ 16
18 98 69 8B
36 43 14 36
42 14 26
98 64 36
48 69 6B
42
43
9D
=
c,,
;:;·
9·; 1! o., 2 1 D1 38 ED 24 D1 8F 46 4~ F4 00 00 00 04 68 96
.....,
0
9~50.134 3F 40 00
9;60.,69 BB 9F 43
00
00
00
00
68
00
93
D2
89 60 F4 00
1D lB 98 BA
6F l-1-3 F4 AF
00 00 0B
D2 1D lB
4D F~ 3F
98
F4
45
z--4
==
(iQ. 9·.· 70~ AF 4B F 4 D2 Ir 42 F4 D1 m
..,,
-::::=-
iO
9;33.,F4 6F 48 F4 9F 43 F4 F4 F4 F4 13 56 35 1D 21 Dl
9·;9 (~., 39 D2 1D 1I3 98 B9 D2 65 86 12 Dl D5 D2 21 D1 B9 ~
so
= 9·;{-.rz,., FL1 36 6D 26 42 14 26 L1F 4F 4F 4F 4F 4F 4F 4F 41 z
G)
C.
9 ·; TJ., 2 4 6 2 iJ 1 2F L!F 4F LJF L1F l(f" 4F 4 f 4 LJ 2 1 Dl BD 22 --4
I
9~C0,14 2F 4F 4F 4F 4F 4F 4F 4F 4D lB D2 12 41 2D lB m
9·.·00, D2 IF 4F 4F 4F 4F 4F 4F 4F 4D 19 BD 21 2D lB D2 ""0
m
iO
9·.-EG, 1 D 19 :;30 21 24 62 41 24 63 96 84 9F 44 F4 1 F LID ""O
I
9 ·; F 2i., 1E 9 9 7 6 4 2 6 /1 7 6 8 9 1D 0B Dl 92 89 F4 3F 36 CC m
,0
)>
-
N
~
,-
CJ)
N
~
N ~
n
;;o
Coded Music for Left Hand 0
"'U
;;o
0
n
m
8•00,FF 00 00 00 00 0D 19 BD 21 2D lB D2 ID 19 D2 4F
(/)
(/)
8~10~4D 14 F4 00 00 00 24 68 9 6 84 9 F 43 Ft.. 9F 43 FLJ 0;;o
~
cio.
. e·.·20., D3 IF 4D 24 F4 6F 48 F4 9F 41 F4 3F 44 F46F 48 z
....
~ 8;30,F4 9F 4F 4F 4F 4D lB D2 13 41 3D lB D2 4F4D 18 m
....
I
8~40~F4 9F 4B F4 D2 lF 43 F4 4F 41
;;o
~ F4 Dl 8F 4F49 BF "Tl
..
YI
8~50,4D 0B F4 0D 14 68 96 84 BF 4D 24 F4 3F 44F4 6D
)>
n
:: 8-.- 60, l B D2 13 41 3D IB D2 6F 4B F4 9F 4B F4 4D34 21 z
=
r,,
;:;· 3-.· 70, D2 BD 32 14 2F 41 F4 2F
G)
....
/1D 2B F4 D3 16 LJ2 14 26
....0
..
r:--c
8~80,4F 42 F4
s--.·9 0, 21 D2 B9
4F
8B
41
9D
F4 27
31 D2
64
B9
26
86
47
58
64
69
21
8F
D2 BD 32
4 1 F4 BF
14
4F
m
()
I
z
....
~
~
s·.-A0, 4D 31 D2 93 64 36 58 69 8B 9D 31 D2 BO 32 IF 4D D
C
::c s·.-Bc., 26 F 4 D3 lF 1-!D 21 F4 6F 4D 16 F4 00 00 D3 01 D2 m
(/)
~
= [:f.-C0,B9 8B AD 31 D2 BF 4F 4F 4F 4F 4F 4F 4F 46 39 B8
Q.
B~D0~96 BF 4F 4F 4F 4F 4F 4F 4F 43 98 69 83 9F 4F 4F
8~E0~4F 4F 4F 4F 4F 44 67 96 74 6F 47 F4 6F 44 F4 2F
8~F0~4B F4 9F 47 F4 6F 4D 32 F4 lF 4D 2B F4 3F 36 CC
P.•CG,D3 ID 1B D2 12 41 2D 1B D2 IF 4u 19 F4 BF 4D 21
A. 1 0., r4 2 D · 1B D2 12 4F 4D 14 F4 D0 9F 4F ~F C0
INTERFACING THE PERIPHERALS
umns, requiring only 64 refresh cycles. The 2116, a recent 16K RAM,
is structured in two arrays and organized in 64 rows by 128 columns.
Because both arrays may be accessed simultaneously, only 64 refresh
cycles are required.
Refresh Control
ROW
ROW ADDRESS
DYNAMIC
RAM
ARRAY
MUX
ZERO DETECT
1--c_o_u_N_TE_R~-(BURST MODE)
243
MICROPROCESSOR INTERFACING TECHNIQUES
Memory Contention
Both techniques require getting access to the memory when it is
not busy, and at a higher priority than the processor. Two main
techniques are used to achieve such synchronization:
Asynchronous Access
Requests are generated at a fixed rate, such as every 31 micro-
seconds (i.e. 64 times every 2 milliseconds), independently of the
microprocessor state. This method is microprocessor-independent,
but requires complex controller design and results in access delay.
The controller may have to wait for the completion of an RAM cy-
cle in progress; however, this is a refresh delay, not a delay of the
MPU. Request priorities must be resolved, and propagation delays
through the controller logic must be allowed for.
Hidden Refresh
The principle of this method is to refresh the RAM while the
MPU does not need it. Hidden refresh is also known as
Transparent Refresh, or Synchronous Access. For every MPU,
situations normally exist in which it can be guaranteed that it will
not require the use of the memory for one or more cycles. If such
states can be identified externally, a refresh cycle can be started
ADDRESS MUX
REFRESH
t
CLOCK
MPU R/W
BUSY MEMORY
R/W
REFRESH
244
INTERFACING THE PERIPHERALS
ASYNCHRONOUS
EVENT -----
Jl.Jl..fL ______._ CLK
D Q ) - - - - - - SYNCHRONOUS SIGNAL
REFRESH
REFRES A£R +sv
Q - HOLD
BAUD REQUES 8080
GENERATOR CLK MPU
HLDA
02
(TTL)
DELAYED
REFRESH
ACKNOWLEDGE RESET
I
245
MICROPROCESSOR INTERFACING TECHNIQUES
QUAD COUNTER
Vee
ENDOFT3
.__...J\N'lr--4 D Q --◄ D Q---
02
8224STB - - - - - - - - - ~
REFRESH
REQUEST
LOGIC --o a-----o
START
REFRESH
FETCH
STATUS
ADDRESS BUS
ROM
DDRESS
ECODER
- - - START REFRESH
246
INTERFACING THE PERIPHERALS
Other Methods
A number of other methods can be used. They are combinations of
the above techniques, often taking advantage of the idiosyncrasies of
the specific microprocessor. For example, an asynchronous refresh
can be clocked by the low-to-high transition of <1>2 (phase 2 of the
clock). This guarantees that there will be no simultaneous memory re-
quest from the 8080 and somewhat simplifies the design of the arbitra-
tion unit.
Refresh Logic
Refresh-Controller Chips
247
;;o~ ;;o;;o
mm mm
toc D~ ( ) "Tl
LOGlC' DIAGRAM ~o c~
m(/)
(/) ,c
Vee -i-( ~I
~-.
~ R,
OUTP\JTMUX
~ Ao -------1
• c•
"'""'
Ul
..
~
.-·
~
01
I (JO
~ A1 j j l j
s·
fD
I
~
I
I "'VI
""'
:::c
fD I
I
..
N
~
fl)
=-
I
I
/ PRIORITY
A2 j j j j
COUNTER
=
~
.0
;;o
m
"Tl
I
___ 1
1
RESOLVER
DURING = ;;o
-
(") REFREQ REFRESH ~ m
RFi=mJ {IJ (/')
-
0 I
= REFRESH
A3 Aj'-A5
DURING > OJ
[ '"1 C
(°)
:'
,s·
CVREG
MEMORY
RFQUEST
MEMORY
-
=-
-·
~
"I
(/)
-<
-= -¾ I I I I
04
--
S'
RiKY
As T I I I
(/')
~
;;o
-i
)>
R
m
(/)
(/')
INTERFACING THE PERIPHERALS
A130------;:-..:::..:::..:::..:::..:::..:::..:::..:::..:::..:::..:::..:::..:::_::-t-t
A6
I 06
I
I
I
I
14 I
TOTAL I I
I I 7
I I TOTAL
I I
17
I !TOTAL
I
I I
A7
Ao I
Oo
. REFRESH 0-------tH 7
ENABLE TOTAl 6 TOTAL
ROW
ENABLE ZERb
DETECT
7 BIT
COUNT------u COUNTER
249
MICROPROCESSOR INTERFACING TECHNIQUES
DYNAMIC MEMORIES
In review, three methods can be used for refresh: group refresh, i.e.
all thirty-two rows every two milliseconds, dedicated refresh for one
:i:
u
l-
e{
..J
I-
:)
0
c{
l-
e{
a
Cl)
"'
..J >
c{
w:.: ;j a:
I- u u a:
- ..J
a: 0 > c{
le u :i!' >
:!E a:
::) 0
0 ::;;
w
:.
z z
0 Q
:it:~- :,,:I- N
u c{ • u<l .
ca: o oa: o
_.w z I-
..JwZ
Uz
w
uzw
X
::) 6owgj ... ... "'...
::) : - ct
w
C, C, :!E c{ a: ~ ::)
Ill
w
l-
a: "'u
c{
le
250
INTERFACING THE PERIPHERALS
1 16
2 15 CAS
D
1
WR J 14 Do
RAS 4 13 As
5 12 A3
Ao
A2 6 11 A4
7 10 A5
A1
8 9
251
MICROPROCESSOR INTERFACING TECHNIQUES
_ _ _ _ _ _ _ _ _ tRC - - - - - -- ~
RAS tAR I
. __ _ _ _ _ _ _ _ tRAS--.-
----..,.
tcSH ' ----!
n_-r_._
_;.I tRSti--.....,.,.i
i - - - - - - 1- -1RC
RAS v ,Hc - - - . . i L-----
..,___ tAR • I
RAS-----.i
I.J"- - - - - - , i _
VIL ..___ _
•---
1 - - - - -r- - -'- tcsH
11RS;tt----~
,_-+f<,___...;,' 1CA,,,___ _,
CAS V 1HC - - - - - ' - - ' - - - - + - - - . . ~----1,------ -
V1L
ADDRESSES VtHC
VIL ,_ __l _____ tcwL
~ 7
l 'cws_1
twci+-
vIHC ~---t-...:ii-_....'....____:~twp
r-: =---+--------
WRITE I
VIL
1 1RWL
1 - - - --
D1N ~:~C-
- ---;-1-~-~~ ~:;:::" )------------
DouT VoH - - - - -- - - - - -
Vol OPEN
252
INTERFACING THE PERIPHERALS
START
STATE
RAS
CAS
RSWSE
DATA
DATA BUS
VALID
253
MICROPROCESSOR INTERFACING TECHNIQUES
WO
254
20MHZ
INTERFACING THE PERIPHERALS
to
I
I
CEf' I
SSTB C COUNT
IJ.. I
+S IJ.. CET ER I
t7
RESET
R
RAS
RS, WSE
CAS
The basic Read and the basic Write cycle requirements for the SlO0
bus are now satisfied. The status strobe signal has been used. This one
signal is the key to our entire dynamic refresh system. If any other
processor besides the 8080 is used, this status strobe signal must be
identical to the timing requirements that are necessary in the 8080 base
system. Besides this, any other operation, such as the front panel, or
DMA cycles, must also follow through this same state sequence. Un-
fortunately, there is no agreement among the SlOO bus manufacturers
as to the actual Read and Write cycle requirements under these alter-
native conditions.
255
MICROPROCESSOR INTERFACING TECHNIQUES
"RAS ONL V" REFRESH CYCLE
RAS
Row
ADDRESS
Dour ---------OPEN
MK 4116-2
PARAMETER "YMBOl MIN MAX UNITS
256
INTERFACING THE PERIPHERALS
257
MICROPROCESSOR INTERFACING TECHNIQUES
20MH2
CYCLE
STA£:T
LOGIC
8080 R
STATUS
8080 W
f
FROM S100 BUS
OMA R
CONTROL ST c;NAL
~
D~ W
FP R
LOGIC
CONTROL
FP W
REFRESH
ADDRESS 4K
Al 5
4K
RAM
& ARRAY
4K
AO ECOD1N
4K
258
INTERFACING THE PERIPHERALS
of the board. A block diagram of the control scheme for this board
appears in Fig. 4-165. Note how in order to determine the present cy-
cle of operation that many status signals are 'used from the bus. This
means that any OMA device must also generate these same signals.
In summary, a dynamic memory system was built by looking at the
timing requirements of the chips and at the timing requirements of the
system. The use of a synchonous-state system simplifies and defines
the system timing. As an example, it was assumed here the designer
had access to the system clocks, so that under all conditions it was
known what the system processor was doing. The use of asynchronous
one-shots, RC time delays, and delay lines may also lead to a working
design; however, these designs suffer seriously from timing problems
related to tolerance of components, change of temperature, etc. The
added complication of Wait states, different system clocks, and the
lack of complete status signals on some buses and the lack of agree-
ment on these same signals, brings abut the practical result of there be-
ing no general-purpose dynamic RAM boards which can be universally
used on any SlO0 bus. The more valuable boards, such as the
Dynabyte product, can be configured to work in particular systems
through the use of hardware jumpers, although there are some
systems where even this amount of flexibility is not adequate. In con-
trast, if we look at the 6800 bus for the Altair 680B, we see that the
system timing is so well-defined as to highly simplify the interfacing
problem.
The design of a dynamic memory board is quite often made even
more complex by the triple power supply and noise bypassing pro-
blems. In fact, such a design quite often results in a memory which
cannot reliably Read and Write information. Therefore, the design of
a dynamic memory system should be considered carefully from the
various points presented, including the difficult area of high-fre-
quency noise spikes induced by normal chip operation. The best refer-
ence for the design of a dynamic memory system is the manufacturer's
memory handbook. Since memories are the bread and butter of the
semiconductor manufacturers, they are more than happy to help
memory board designers in using their product.
SUMMARY
The progress from PIOs, UARTs, and other simple LSI chips to
FDCs and CRTCs points towards the trend of the technology. More
peripheral controllers will be fully integrated onto a single chip, and
259
more controllers will be ''intelligent.'' Local editing, file libraries, text
processing will become standard features on the peripherals of tomor-
row.
260
5
ANALOG TO DIGITAL
AND DIGITAL TO ANALOG
CONVERSION
INTRODUCTION
261
MICROPROCESSOR INTERFACING TECHNIQUES
A CONCEPTUAL DIA
BIT3
BIT2
R
BIT l
BR
BIT0
OPERATIONAL
AMPLIFIER
Let us begin with all the switches in the open position. Since there is
no input to the operational amplifier, the output will be "0". Closing
262
ANALOG CIRCUITRY AID AND DIA CONVERSION
'
the bit switch numbered "O" will apply the - lOV reference to the in-
put of the operational amplifier, through the resistor marked SR. This
will result in an output voltage of 1.25V (due to the gain of - Vs at this
point). Closing the switch marked "bit l" will then add 2.5V to the
previous value (1.25V) (due to the gain of - ¼ at this point). The
resulting output is 3.75V. If all switches· are closed, the resulting out-
put voltage is 10.0 + 5.0 + 2.5 + 1.25 or 18.75 volts. Here, we have
converted a 4-bit binary number, represented by the four switches, in-
to a voltage. It is the analog representation of one of the 16 possible
digital values.
We will now examine the structure of a practical DIA converter.
A Practical D/A
The practical design in Fig. 5-2 illustrates the typical design for a
monolithic DIA converter. This device has four bits of resolution.
Practically, currents are summed instead of voltages, due to the fact
that currents are easier to switch on and off accurately. To provide a
voltage output, the last stage of the converter becomes a current-to-
voltage converter. This is easily done by an operational amplifier.
Typical converters have eight bits of resolution.
DATA LINES
BIT SWITCH
BIT SINK
RES. NET.
263
MICROPROCESSOR INTERFACING TECHNIQUES
LOGIC
INPUTS
REFERENCE BIT
CURRENT SINK
BUS
LADDER NETWORK
264
ANALOG CIRCUITRY AID AND DIA CONVERSION
V REF
l r
6 T I i
I
n
6
MSB lSB
I REF l i l l I
t
1/20 1/20 1/40 1/80 1/160
- lOV 50 so 50
cuitry. When the input is a logic ''O'', which corresponds to OV, the bit
sink will draw current through Q4 to the bit-sink bus. When the input
is a logic "l ", which corresponds to an input voltage greater than 2V,
the bit sink will draw current through Q3, instead of Q4, disconnec-
ting the bit-sink bus from this sink bit. The four binary signals will
switch the four bit sinks on and off the bit-sink bus. The resulting cur-
rent is converted to the output voltage.
+5V
4
' Q FROM OTHER SINKS
-V
BIT SINK
Real Products
Sampling
266
ANALOG CIRCUITRY AID AND DIA CONVERSION
1 CYCLE )II
267
MICROPROCESSOR INTERFACING TECHNIQUES
268
/
COMPARE
MSB LSB
Guess 4: 11010000 - - -
In other words, whenever the actual input is greater than the ap-
proximation, the current bit is left on and the next bit is "tried".
269
MICROPROCESSOR INTERFACING TECHNIQUES
Whenever it is not greater, the current bit is turned off and the next
bit is tried. The algorithm is presented formally on Fig. 5-10. The cor-
responding hardware is shown on Fig. 5-11.
NO
YES
ERASE CURRENT BIT (BIT=0)
END OF APPROXIMATION
270
ANALOG CIRCUITRY AID AND D/A CONVERSION
ANALOG ANALOG
INPUT OUTPUT
OOR 1
ONE-BIT
LATCH
BIT ADDRESS
COUNTER .,__
N-BIT LATCH
DAC
271
MICROPROCESSOR INTERFACING TECHNIQUES
SIGNAL
V2
INPUT
V4
-------------------·
---------~
V3
Vl
TIME
+ + I
0
+ + +
Fig. 5-12: A Sample Approximation
272
ANALOG CIRCUITRY AID AND D/A CONVERSION
Connecting a microprocessor
Instead of implementing the control logic in hardware, a microproc-
essor may be used to test the result of the comparison and generate the
next digital approximation. The resulting diagram is shown on Fig.
5-13. The corresponding hardware logic is replaced by a simple pro-
gram.
ANALOG
INPUT ------- M
I
C
D/A CONVERTER R
0
p
R
0
C
E
OUTPUT REGISTER s
s
0
COUNTER R
Fluctuating input
It has been assumed so far that the input value does not change dur-
ing the conversion. If it did change, the conversion might no longer be
accurate. A simple solution to this problem is to use a sample-and-
hold circuit (S/H) to freeze the value being approximated. The opera-
tion of a sample-and-hold circuit is shown on Fig. 5-14. The resulting
system interconnect is shown on Fig. 5-15. A sample-and-hold circuit
will normally be used unless the input signal varies slowly and is noise-
free during the conversion process.
273
MICROPROCESSOR INTERFACING TECHNIQUES
-- -- _
7
HOLD OUTPUT SIGNAL
I
I b.
I I i\,
~
I I
- - , HOLD OUTPUT
I l
I I
I I ,r:;------ TRACK
I I ......
/
--✓ I
I I
I
I I I
SAMPLE SAMPLE I SAMPLE
I□ I I
HOLD HOLD HOLD
SAMPLE
HOLD ADC BUFFER MPU
274
ANALOG CIRCUITRY AID AND DIA CONVERSION
INPUT
. TOO HIGH
(
TOO LOW
275
MICROPROCESSOR INTERFACING TECHNIQUES
Integration techniques
CHARGE
TIME PULSES
0 1000 1000 + N
276
ANALOG CIRCUITRY AID AND DIA CONVERSION
II•· 0
O!:'.
~
u
I-
z 0
~
0 u
u
O!
0
I-
<{
O!:'.
t,
w
I-
z
,, I•
I
ut-
-
1
z
T u..
w
- a::
>>
277
MICROPROCESSOR INTERFACING TECHNIQUES
In the first phase, the capacitor is charged under the (positive) input
voltage during n pulses (1000 for example). A capacitor charges at a
rate proportional to the input voltage, or more exactly to the average
input value over the time "T". T is a predefined period of time.
In the second phase, the capacitor is discharged by a calibrated
(negative) reference current. V,cr (of opposite polarity to Vin) is ap-
plied. The time required to discharge the capacitor is measured. It is
"t".
When used in conjunction with a microprocessor, the input is gen-
erally scaled and offset by V,cr divided by 2, so that:
t- T = y2 (Vin + l)
T Vref
In other words, the value of the counter essentially provides the
digital value of Vin• The complete diagram of a bipolar dual slope
ADC is shown on Fig. 5-19.
START
CONVERSION
COMPARATOR
. - - - • STATUS
CONTroL
,_ - ■ LOGIC
+
CLOCK
RESET
COUNTER
BINARY OUTPUT
278
ANALOG CIRCUITRY A/D AND DIA CONVERSION
Quad slope
Quad slope is directly derived from the dual slope technique. An ex-
tra charge and discharge are performed initiaJiy in order to reduce
some potential errors. The technique integrates inaccuracies caused by
offset and ground errors that may be present. The corresponding
waveform is shown in Fig. 5-20. The method derives its name from
the four slopes.
AGND
VREF ~ O R
-"N"v----4>-\(CLAC Mj 0
AIN -0 I
PHASE PHASE PHASE
ONE TWO FOUR VREF
START - ---,-J
(TO 2
I CROSSING)
l. , AIN '
2
FIXED 1 NEGATIVE I '' -souDUNE
I ' NO ERROR
···DASHED LINE
AGND ERROR +V
279
MICROPROCESSOR INTERFACING TECHNIQUES
ANALOG - - - - - l ~
IN
CONTROL14--- START
+
CLOCK
DAC
COUNTER
+
REGISTER
280
ANALOG CIRCUITRY AID AND DIA CONVERSION
VALUE
DIGITAL APPROXIMATION
INPUT
The input is compared to the DAC output, and the counter counts
up until the approximation becomes larger than the input.
The technique is very simple, but has limited speed. It may take a
long time for the approximation to finally reach the value of the input.
This is because no specific technique is used to reduce the length of
time necessary to search the possible interval. In some cases (low input
values) the approximation will be obtained quickly. However, in the
general case, the method will require n/2 counts, where n is the maxi-
mum value which can be achieved with the counter (n = 2p where p is
the number of bits in the counter).
281
MICROPROCESSOR INTERFACING TECHNIQUES
It will follow small changes rapidly, and can provide the function of a
sample and hold circuit.
The basic tracking circuit is shown on Fig. 5-23 and the resulting
approximation is shown on Fig. 5-24.
COMPARATOR
DAC
COUNTER
DOWN
CLOCK
INPUT
OUTPUT
SAMPI.E SAMPLE
CONTl!Ol HOI.O
282
ANALOG CIRCUITRY AID AND D/A CONVERSION
PARALLEL CONVERSION
INPUT Vx
PRIORITY ENCODER
OUTPUT
Let us examine how this works. We will consider a 3-bit direct com-
parison converter. Our input can be measured in terms of eight levels.
Figure 5-25 illustrates the structure of our converter.
283
MICROPROCESSOR INTERFACING TECHNIQUES
VREF
284
ANALOG CIRCUITRY AID AND DIA CONVERSION
, 1101
1111
112)
I 131
111
121
(31
(4)
(5)
Output Conttol
MULTIPLYING DAC
The term "multiplying DAC" is frequently encountered and simply
refers to a DAC which accepts multiple references. It may operate in
1, 2 or 4 quadrants.
285
MICROPROCESSOR INTERFACING TECHNIQUES
MONOLITHIC ADCs
Type of
Manufacturer Type# Resolution Speed Conversion Cost
National MM5357 8 40us SA $10
PMI AD-02 8 8us SA
Analog Devices AD7570 10 18us SA $70
Date! ADC-EKl2B 12 24ms Integrating
Analog Devices AD7550 13 40ms Integrating $25
National ADC 0816 8 114ms SA $20
286
ANALOG CIRCUITRY AID AND DIA CONVERSION
CLOCK
START
ADC : CONTINUOUS
CONVERSION
287
MICROPROCESSOR INTERFACING TECHNIQUES
SOURCE
r----,
TALK ' LISTEN ;
HANDSK~KE 'L - - - _J'
DEVICE
DATA
LAST
BYTE
INDICATOR
ATA
1 - - - - - - - - - - - - - ATN
..----------EOI
~------.!BYTE
\ XFER
r---,
DEV, DATA
I I ACCEPTOR
I TALK HANDSHAKE
I I
L.- - - .J
288
ANALOG CIRCUITRY AID AND DIA CONVERSION
CLA l"Olf I)
51RTINOTU2ANOIJ _ _ __.
NUILS,
I. ln.crnal Clock Runs Only During Conversion Cycle I External Cl<1~k ~howo/.
2. Ex1crna.Jly Initiated
3. Serial Sync L1&5 Clock br, ,. 200 n,.
4 . Do11ec.l Lines Indicate "Floacinf' S1a1e.
S. For Illustrative Purpose,, Serial O~-• Shown u I 101001110.
11
6. Cro~s llardun1 Indicates ••oon't C..Mn: Su1c.
7. ~Cl m.J lfr,cl of o,nrut D•u Hi,, l•l,"' Clud, l'o,itive Fd~c l,y " 200 ....
8 , Tr•ilrn)? l'~J~~ of STKT Should be' E.>.h.·rJ1all)· Synchruni.tcd 1'• I L:.-d,ni! rd~t· ot < I t\.
9. Shown for SCI; a I.
ADDRESS BUS
AD7570
AOC
MPU
00
OATABUS
289
MICROPROCESSOR INTERFACING TECHNIQUES
.. ~
J•
>- -
-
I zw
~z Oz ca
ca
~, o- - "" 0
LO
Oz
-
_,.J
N38H ..,_
z
I alco z
- -· I
0~
o-co
-- <(
~
<( z
-z
-ow
(/)
(0 (/) co
I
(/)
::>
0~
- I
h
-
..,,
(0 I
~ I
<( I
0 I
u I
--
>-
(/) zca
::> ,- --
-
- I
oai
ca "
0
LO
" 0
Oz
, -• -
- ' w
_,.J
N38H _ 2
co(/)
--~z
--
I Q _,.J
<( ,-
- I
~
o- ca
-
-
w
(/)
cor.n ca ,-
... 1111"
Q~
- ~
u
+ -
..,,
Oc
_,.J
0
u w
IL
~
>
290
ANALOG CIRCUITRY A/D AND DIA CONVERSION
AGNO 0---
8
--1
2
5
LOTR
RFB1
4
RFS2
6
IOUTl
7
IOUT2
lSB
22 LODS
SHtFT REGISTER
(SERIAL MOOE!
LATCH
SHIFT REGISTER {SERIAL MODEi
LATCH (PARALLEL MODE)
-1-
26
- -1--0 SR I
(PARALLEL MOOE)
12 13 14 15 16 17 18 19
291
MICROPROCESSOR INTERFACING TECHNIQUES
w
::::,
.....J
<(
>
0-~
I
co zUJ
/
~o
C I-
,Ill ~ <(U ,...._
o<C
....JC 0
I
UJ
c:o
I- C
<( C
C <(
a.. 0
::::, .....J
C u
C u
> >
u
<( (/)
r-
C co
C ....J :x:
I
0
0 N 0,.
I
-- --
,.... '" .
CX)
.co N
A "-C N
..._ I lO
... co ..
~
0
co
Q
,...._
C
<(
~"'"'
::::,
a..
~
292
ANALOG CIRCUITRY AID AND DIA CONVERSION
SRI SPC
SERIAL DATA IN
----Vee
vDD
293
N
',c
~
SERIAL DATA
8-BIT
. I 10-BIT ...
~
n,0
0
I I I I I
"'ti
YI CLOCK IN
1 2 3 4 5 6 7 8 9 10
z
-I
m
~
..r.r,
...,I ( l 0-BIT MODE) ,0
"Tl
:t>
..-·
~
n
z
--·
so G>
►1 I
-I
~ LOAD DAC m
a UPDATE TIME n
-·
::s
(JQ
(10-BIT MODE)
A
J:
z
=
..-·
so
rJQ
l 2 3 4 5 6 7 8
D
C
m
(/)
so CLOCK IN
a (8-BIT MODE)
LOAD DAC
(8-BIT MODE) UPDATE TIME :::I I
MICRO-
~ ...·~
PROCESSOR (, 8-BIT DATA BUS
~ .
~
' J( J l J' ~ J• Jl H, l ~ l j l J u ...
~
.--
J ' .J
~ MEMORY ' j
tie WRITE .-
(A
I
MEMORY
~
.. -,...
-
QC READ -
1:8 7 ) oR)-.- LDAC
s: -
)>
= z
D 6 )>
r.i
!,
.. =-·
-· = r.i
A0 Al5
I -
~ ~ E ...
r - HBS AD7522
r-
0
G)
,0, (1Q
\ AND}+ C 4 - LSB ()
a~ I -
;;o
()
~ = ,. - 0 3- C
::.
..0,,- lOR
Cll
rll - .
: ;;o
D 2 - -<
f l)
> .. ~
) A2 E 1 - LDAC
~
t::, 0
~ I' A0 0 - HSB
~
AD7522
)>
~ l z
-,.... LSB 0
-
Cll
Cl
0
>
', H>
1,
H> 8z
(1
<
m
IJ 1J 0 ;;o
(/)
~
UI AOUT2 AOUTl 0
z
MICROPROCESSOR INTERFACING TECHNIQUES
... ..
8-BlT DATA BUS /DO-D7l
... I
.,
'
,,
'
o-
cccc
I ,1
' +.
~·~
d jj
N>- Cl
-V) Cl::
co Co cc::,> --oHBEN (HIGH BYTE ENABLE)
Ceco
~LBEN /LOW BYTE ENABLE)
AD7550
--oSTEN (STATUS ENABLE)
l---0
START
296
ANALOG CIRCUITRY AID AND DIA CONVERSION
/
. ..
MICRO- ,,
PROCESSOR "
' ' ,, '
-~ ~ ~ 4 ._S_
TR_T""T"""_~__,
-----/ ~ 0 31-------\
I
~------_,,.)
D 21---~
L--_ _ _ _ _ _,..._.. A2 E ' J 1 - - - - ,
I
HBEN
LBEN
r AO 07 '----f---~-..C
STEN AD7550
L----~--4---~START
(
AIN2
( 1 AINl
C
297
MICROPROCESSOR INTERFACING TECHNIQUES
8-BITS
OUTPUT ENABLE
SC
EOC
+sv CLOCK
-5V 0 -12V
298
ANALOG CIRCUITRY AID AND D/A CONVERSION
DATA BUS
8205
al
a2
:g...r-....
a6 n-e-+----,
a7 -,___ _, 7 LS20
299
MICROPROCESSOR INTERFACING TECHNIQUES
ANAlOG
t4"-t--t---+- INPUT
GAIN ADJ
~ - - - - - i SUMMING NODE
The MP21
300
ANALOG CIRCUITRY A/D AND D/A CONVERSION
•"' "'
ii!
Ill
)(
2
Ill
)(
..
Q
:, :, "i
::I ::I ;;
AO 8 CHANNEL 8 CHANNEL
LATCH ANALOG
A1 ANALOG
..
;
A2
A3
MULTIPLEXER MULTIPLEXER
~ ...
"'a0
.. AO DRESS
DECODER
AND
CONTROL
CONTROL
LOGIC
...-
"'-15 LOGIC
INSTRUMENTATION
GAIN
!OFFSET
ADJUST
ADORE
SELECT AMPLIFIER IAMPLIFIEI\
;"'
.J "" ~/]i ..
0
ii!
:I
POSSIBLl
SAMPLE
ANO
:I ,------0--'HOLO
0
11..~,
~ HALT
CONTROL L.OGIC
....
u
a:
1.251< 8.2!U(
HERE
>
INT 2 . __ _ _ _ - - - 0
0
u
.."'
:,
STATUS
....
<
0
RI-STAT
OUTPUT
8 BIT A/0
CONVERTER
DI
>-
~-
"' 0
0 ..
All necessary interfacing has been done for the user so that the
module will be as simple to use as possible. Fig. 5-45 indicates the
signals necessary for a typical application utilizing a 650X or 6800 pro-
cessor.
301
MICROPROCESSOR INTERFACING TECHNIQUES
ADDRESS BUS
ESET
INT
....
Cl)
::>
0.
VMA
MP21
-c.,z R/W
6800
0
...J 02
<(
2
<(
DATA BUS
Scaling
If the input signal is 1.0 volt and the full-scale intput of the AID is
+ 10.0 volts, we should increase the gain of the amplifiers before the
AID converter, so as to take advantage of the full-scale resolution of
the AID. By increasing the gain by a known amount, we can measure
smaller signals more accurately. If the input were 20.0 volts, we could
decrease the gain of the input amplifier in order to attenuate the input
signal. This will allow us to measure larger voltages than could other-
wise normally be measured. By these examples, the need for scaling
becomes evident. We scale the input to obtain maximum information
upon conversion from our AID converter.
302
ANALOG CIRCUITRY AID AND DIA CONVERSION
Offset
By connecting the output of a separate DI A to the offset input
before our amplifier, we could automatically correct for offset errors,
or we could offset a voltage to increase the accuracy further. If the in-
put is 10.0 volts and we are interested in small changes around this
value, we can offset the input by an equal and opposite amount. The
output of the offset DIA is then - 10.0 volts. Adding the two
together, we get some small value which depends upon the difference
between the offset DI A and our input voltage. Now, we increase the
gain of the input amplifier so that any difference between the input
10.0 volts and the offset 10.0 volts can be measured with the full ac-
curacy of the AID converter.
IX X X X X X X Xxx XX X X X X X XI
±JO VOLTS (+ 10 VOLTS)
xl
xlO
xlOO
303
MICROPROCESSOR INTERFACING TECHNIQUES
The D/A converter requires a parallel digital word that will remain
stable as long as the analog output is needed. This is easily
accomplished for eight or fewer bits, since most microcomputers have
output latches eight bits wide. Fig. 5-47 shows such an interface. In the
case where the DIA has more than eight bits of resolution, special
techniques may be required for interfacing.
LATCH 8 BIT
-
D/A
- ~ AN ALOG OUTPUT
--V
-
-
.
DATA
BUS
STROBE l t
8 BITS
HIGH
DATA BUS LATCH 13 BIT
MSB
DIA
5 HIGH
BITS
LOW LOW
LATCH HOLD
LATCH
8 LOW
BITS
304
ANALOG CIRCUITRY AID AND DIA CONVERSION
ANALOG
OUT
(DA 1200)
74LS374
NWDS 23
DECODE
5 20
0 -------1
6
+5V
22
2.,.__ _ _7....
OFFSET
DAiA 8
B:JS
3 t-----1 -=
4 -----;.a
9
10 14
+lOV
6 -------1.1
5 -------
7 _____.,.
12 MSB
21
305
MICROPROCESSOR INTERFACING TECHNIQUES
STAR r CONVERSION
YES
NO
_ _ _ _ _ (OP_T
ION_Lj
! NEXT CHANNEL
CONTINUE
STORE IN ~\EMORY
306
ANALOG CIRCUITRY AID AND DIA CONVERSION
Using multiplexers
INPUT SIGNAi.
CONDITIONING MUX
(GAIN
TRANSDUCERS FILTERING,
(SENSORS) ETC.)
AID
_
...............
r.=::::::::;►CONTROI.
307
MICROPROCESSOR INTERFACING TECHNIQUES
CONTROL
JJ.
MUX DIGITAL
AID VALUE
S/H
An 8-to-J Multiplexer
308
ANALOG Cl RCU ITRY AID AND D/A CONVERSION
.,_
::>
.,_
0..
::>
0
.~
~·
-L
~- "°Iii
w
...J
Ii)
·;><l- <{
zw
I l- j
··~
-
j
.-l - 1
-
-
~
- - ::...,-
~
?:=!
- -- -
c./)
~~
- - ;;;_r
) I) ) ) ) I) ~)
~5
<{ Q..
oZ
Fig. 5-53: 8 Line Multiplexer
309
-
t.,,I
FILTERED ANALOG
0 1 2 3 4 5 6 7 ~
()
;;o
0
INPUT ";;o0
LINE ()
m
_____ ____
(/'I
~
~- ANALOG MULTl PLEXER 3
(/'I
0
;;o
(II ..,_ .,.... ___. ADDRESS
I
(II "'4----EN z
-I
~ m
HOLD ;;o
> "Tl
= _[7 )>
=
JO ()
. z
-==
(11:1
G>
--1
m
-=
'Cl
()
::z::
~ z
0
-·
:::
'C
[
C
rn
a·
(11:1 DAC
MICROPROCESSOR SYSTEM
- - - - - - - - - - - - - INPUT SELECT
ANALOG CIRCUITRY A/D AND DIA CONVERSION
N
<(
Ck::
0(/) -
<(
(/) 0
w <(
u z
-<(
0
Ck::
a.. I-
0 <(
Ck:: Q
u
~
C
C
(/)
<f)
II•·
> >
u
C
<(
_____________.o
I-
::>
311
MICROPROCESSOR INTERFACING TECHNIQUES
A 16-channel multiplexer
INPUT
s, U-"t------------------"J
S2
S3u-"t---------------.J..J.
S4 : H f - - - - - - - - - - - - - . . . . . C
S5 r - t - - - - - - - - - - - - - - - n
S50-+-----------.0
I I I
S70-+----------.0
I I I t
Ssr>-+---------O
I I I I
Sgn-~-------~J
OUTPUT
S10r>-+--------io I I
s, 1 0-+-----__ju
s,20-+-----u_
5 1Jc.>--t-----u
S140-+---U
S15 ) - - f - - 0 I I
I I I
51sr>-+-O
I I I
A3 A2 A1 AO ENABLE
312
ANALOG CIRCUITRY AID AND DIA CONVERSION
c., .=-
95 ~
<i:z~~
<{ -o
0 0
- - - - 1?
-z -
-
I-
:)
(/')
C"I
(/')
c.o
...--t
(/)
HII•· w u..
0 0:::
c., - - >
0
--J
<{ - ~1
z
<{
0
<{
-
<{
N
<(
M
<{ z
-+
I S
<{ co u 0
C, C, C, C,
>-0:::M
wo-
HIii·
I - 0::: I - u >
0 cc<(Z"'-1' v~
+ •Z:::),-....
,q--o~ +
cou~
-z ::::::J-
cc <C -
z
'
~
u
0
--J w
u --J
co
<{
zw
Fig. 5-57: 16 Channel Sequential Multiplexer
313
~
~
~ n
~
,:,
;o
z
<.II
1 0 0 0 0 0 ON _ _ _ _ _ _ _ _ _ _ _ _ _ _ - - -- - -
I
<.II
~ l 1PULSE I O O 0 - ON __ - - - ____________ - rrl
~
_ _ ON _ _ _ _ _ _ _ _ _ _ _ _ _ _ - . _ _ _ _
n►
00 1 2 PULSES O 1 0 0 _ _ _ _ ON _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tD
.c 1 3 PULSES 1 1 0 0
= 1 4 PULSES O O 1 0 z
tD
-_ _-
_-
_- _ON .--. - - - - - - -
_ ON _ _ _ ._, _ -
_-
_ -_ _-- -
__ --- G)
a.... l
1
5 PULSES
6 PULSES
1 0 l
O 1 l
0
0
_ _ _ _ _ _ _ _ _ ON __. _ _ _ _ _ _ _ _ _ _ _ -I
m
!. n
l 7 PULSES 1 l l 0 - - - - - - -ON- - -- - ---
a: 1 8 PULSES O O O 1
J:
z
=
iiliC l 9 PULSES l O O l
-
-
--
--
-- -
- -- -- -
--ON-------
- - - ON - - - -- - -- -
0
C
~
l l O PULSES O 1 0 l -- - -- -- - -- -- - - - - -- ON - - __ _ m
U')
l 1 1 PULSES 1 1 0 l - - - __ - - - -- -- - - ___ ON _ - - - -
~ 1 l 2 PULSES O O l 1 --- -- --- - _ _ _ QN _ _ _
~ 1 l 3 PULSES l O 1 1 - -- -- - -- - - -- -- - - - - - -- _QN - -
-
r::,'
tD
1
1
14 PULSES
15 PULSES
O
l
l
l
1 1
l l
- - - --- - - - - - -
_ - -
_ - _
-- _
--- _
-- _
- _
- _ - · i'
ON ON
--···-··-----~-----'-~----------------
ANALOG CIRCUITRY AID AND DIA CONVERSION
l'!SB (22>
IIJX ENABLE S/H INPUT Bil 2 (23>
BIT 3 <24l
(17) <16)
Bil 4 C25J
BIT S <26l
BIT 6 <27>
CH O (8) AID
BJT 7 <23l
CH l <9) LSB <29)
CH 2 ClOJ
CH 3 Clll MUX E.O.C. C30l
CH ~ (12)
CH 5 <rn
CH 6 (lq) CHANNEL
l Il l
ADDRESS CLOCK/LOGIC
CH 7 <l5l REGISTER
Programmed acquisition
It has been shown that, for any given technique, hardware may be
used to implement the conversion, or else a combination of hardware
and software. Additionally, hardware may be eliminated by multi-
plexing.
The availability of a microprocessor can be used to advantage by
providing in software a number of functions such as: automatic cali-
bration, data compression, data filtering, weighing, averaging, histo-
rical records, reasonableness testing, varying the internal precision,
315
MICROPROCESSOR INTERFACING TECHNIQUES
providing fail soft through tables of values, and finally providing ease
of modification and diagnostics.
Programmed soft-fail
316
ANALOG CIRCUITRY AID AND DIA CONVERSION
Sensor failure
Each type of failure may be either temporary or permanent. Let us
examine these two cases:
Temporary
A temporary sensor failure will be detected by the reasonableness
test.
Reasonableness testing refers to the use of a bracket to determine
whether a given input is reasonable. For example, whenever measur-
ing the temperature of liquid water, a temperature between O and 100 °
C would normally be deemed "reasonable". When measuring the
speed of traffic in the city, a speed between O and 60 mph would be
reasonable.
Whenever "unreasonable" data is received it is automatically re-
jected and will not cause an erroneous reaction from the system.
For example, assuming that a washing machine is equipped with a
microprocessor control system, after telling the machine that the
clothes to be washed are made of cotton, the machine will automati-
cally reject some washing modes as they might damage the clothes. It
would deem them as unreasonable.
Similarly, using a microwave oven, a 20-kilo chicken will be auto-
matically rejected as "unreasonable".
These cases normally correspond to an operator error or else a sen-
sor error. The essential advantage of this method is to filter out noise
on the input line as well as reject any values that might otherwise
throw off the operation of the system.
The operation of a reasonableness testing bracket varying with time
is shown on Fig. 5-60. During the time period TO to Tl, the bracket
LO to HO is used. During the next time period (time greater than Tl),
the bracket LI to HI is used.
The dashed line on the illustration shows the average value of the
measurements during the interval and wiJl provide a backup value in
case all input data should become unavailable.
In summary, any temporary sensor failure will be detected by test-
ing its value against the reasonableness brackets which have been pre-
devined. Whenever the value exceeds these brackets it is rejected, and
a diagnostic may be generated.
Permanent
A permanent failure of the detector is detected by the reasonable-
ness test. It may be defined as permanent whenever the same sensor
317
MICROPROCESSOR INTERFACING TECHNIQUES
MEASUREMENT
• •
• •
• • I • • ACCEPTABLE
• • • I
r-------- MEA$UREMENTS
FAll-BACK • •
VALUE - - - - - - - - J • •
• II • • •
Lo
REJECT
-----------+------------
0
TIME
318
ANALOG CIRCUITRY AID AND D/A CONVERSION
fails n/times during a given time interval. At this point, the sensor
should be ignored. It can be actually disconnected by software by
weighing it to "O", using the sensor weighting technique:
Temporary failure
The only reasonable way to detect the failure of a control device
before actual harm is done requires monitoring it. A status-feedback
is necessary. In order to detect whether a control device has executed
in order, a tolerance bracket is usually necessary. For example, if a
relay must be closed, a time period is tolerated during which the relay
may close.
If a temporary malfunction is detected, the simplest method used is
the "retry". The order is simply given again, and again, up to a maxi-
319
MICROPROCESSOR INTERFACING TECHNIQUES
mum of n times, until the control device obeys. If after n times it has
not obeyed, or if such fai1ure should occur too frequently in a given
time period, it is deemed to be a permanent failure. This method can
be somewhat compared to banging a machine after a coin has been in-
serted and it doesn't work. Usually this simple retry method will pro-
vide the desired result.
Permanent failure
In the case of control devices, and because of their high cost, alter-
nate devices are not frequently available. If one is available, it should
then be activated. If none is available, a back-up control strategy may
be implemented which puts the system in a mode where it keeps oper-
ating at a reduced performance level. At the same time, a diagnostic or
an alarm should be generated.
Power failure
A bootstrap program may be used to start the system in a table-driv-
en scheduling mode. In this mode, the list of actions to be performed
by the system is stored in a table. The system will revert to this mode
of operation whenever a power failure will have occurred in order to
provide immediate resumption of activities in a given mode. It will be
able to switch to another mode of activity once enough data will have
been accumulated to take reasonable action.
Naturally, backup batteries may be used to provide immunity from
power failures for a limited period of time.
System failure
A system failure refers to a failure of the microprocessor system
itself, or its subsystems. At this point, an alternate microprocessor or
another backup device may take over.
Summary
320
ANALOG CIRCUITRY AID AND DIA CONVERSION
I I LJ ~HTING
SENSOR MEASURE I
n=
BRACKET-TEST
AVERAGE
TEST
CONFIDENCE
WEIGHTING
PARAMETER TO
CONTROl
ACCEPTED
ORDER
CONFllC LJ ORDER AlGORITHM
DEVICE
STATUS
TEST
n SYSTEM
TESTS
SELF
DIAGNOSTICS
STATUS
MONITOR MALFUNCTION
TEST
BACK-UP
SYSTEM
SUMMARY
Our microprocessor can now be used to gather information, process
it, and output that information in a new form in the analog world
through the use of these conversion products. The DIA or digital-to-
analog converter, providing the microcomputer with the means for
generating the analog signals, and the AID or analog-to-digital con-
verter, providing the means for measuring the analog signals, form the
basis of any conversion system. The use of sample-and-hold,
multiplexers, and scaling/offset techniques, allow us to quantify any
signal, process it, and pass it back in almost any form we require. A de-
tailed case study of an analog board design is presented at the end of
Chapter 6.
321
6
BUS STANDARDS
AND TECHNIQUES
INTRODUCTION
322
BUS STANDAROS
PARALLEL BUSES
In this basic system, the control bus will have the timing shown in
Fig. 6-1.
These 29 signals are all that are needed for most simple parallel
buses. Timing will vary, and separate read and write lines may be
used, but all buses function in a similar fashion.
Future systems will require at least 16 data lines and perhaps as
many as 24 address lines. Also, many additional control lines are
desirable for flexible input-output management.
323
MICROPROCESSOR INTERFACING TECHNIQUES
VALID
ADDRESS
VM
DATA
01/ff/4< VXJJJ!lt~kt-~
MEMORY FETCH
ADDRESS
R/W
w~ ~~~
/
VM
"
x x
DATA WILL REMAIN
VAlib ONflt AFT ER
DATA WRISES.
MEMORY STORE
324
BUS STANDARDS
PIN
NUMBER SYMBOL NAME FUNCTION
- -- - -- ------ ---- -------
1 +8V +8 Volts Unregulated voltage on
bus, supplied to PC
boards and regulated
to 5V.
325
MICROPROCESSOR INTERFACING TECHNIQUES
PIN
!".'!~~.!!~':!. ~~~~Q.'=- NAME FUNCTION
326
BUS STANDA RDS
PIN
NUMBER SYMBOL NAME: FUNCTION
24 PHASE 2 CLOCK
25 PHASE 1 CLOCK
29 A5 Address Line 5
30 A4 Address Line 4
327
MICROPROCESSOR INTERFACING TECHNIQUES
PIN
NUMBER SYMBOL NAME FUNCTION
------- - ----- ---- -------
31 A3 Address Line 3
34 A9 Address Line 9
328
BUS STANDARDS
PIN
NUMBER SYMBOL NAME FUNCTION
50 GND GROUND
329
MICROPROCESSOR INTERFACING TECHNIQUES
PIN
NUMBER SYMBOL NAME
- -- - - - - - --- - ---- FUNCTION
--- ----
clock generator. Pn-
mary purpose is to
strobe the 8212 status
latch so that status is
set up as soon in the
machine cycle as
possible. This signal
is also used by
Display /Control logic.
330
BUS STANDARDS
PIN
NUMBER SYMBOL NAME FUNCTION
-------
70 PROT PROTECT Input to the memory
protect flip-flop on the
board currently ad-
dressed.
331
MICROPROCESSOR INTERFACING TECHNIQUES
-- -- -
PIN
NUMBER SYMBOL NAME FUNCTION
------ ------ ---- -------
control input; while
activated, the content
of the program
counter is cleared and
the instruction register
is set to-0.
80 A1 Address Line 1
81 A2 Address Line 2
82 A6 Address Line 6
83 A7 Address Line 7
84 AB Address Line 8
332
BUS STANDARDS
PIN
NUMBER SYMBOL NAME FUNCTION
------ ------ - --- ----- --
89 DO3 Data Out Line 3
The other host of signals are control signals. The SIOO bus has far
more than anyone will ever need of these, and suffers from being
designed before a system-controller chip was made available for the
8080. Because of this, many of the signals are due to the original Intel
problem with pin limitations, as discussed in Chapter 2. Obviously, a
new SlOO bus would be needed, with these control signals reduced to a
manageable number. This will probably never happen. A standard can
always be improved; but it won't be-this is why it is a srandard!
333
MICROPROCESSOR INTERFACING TECHNIQUES
The SIOO bus is a practical bus and will perform well in most appli-
cations. The problems mentioned here should be avoided when new
bussing schemes are being considered in the next few years for future
systems.
M2 M3
T1 T2 T3 T1 T2 T3
f1
f2
A1s-o
t BYTE
ONE
\..._/ BYTE
TWO
\
D?-o
--
/ STATUS
•LSB'S ,I) ----I
<,, ______ STATUS
< • ,,
,____
\ "ASB'S 1
PSYNC _J \ t \
PDBIN
t. \ t • \_
PWR
STATUS
INFORMATION xsMEMR xsMEMR
334
BUS STANDARDS
T1 T2 T3 T1
~l
f:2
AJ5-0 MEMORY
ADDRESS
PSYNC
PD81N
PWR
STATUS
INFORMATION ----x WO
335
MICROPROCESSOR INTERFACING TECHNIQUES
IEEE-488-1975
336
BUS STANDARDS
337
MICROPROCESSOR INTERFACING TECHNIQUES
DBE: The DBE input is the three-state control signal for the MPU
data bus and will enable the bus drivers of the 6800 when in
the high state. Phase 2 is used to drive this input directly.
During an MPU read cycle, the data bus drivers are disabled
internally, i.e., within the MPU.
R/W-P: Read/Write-Prime is developed by NANDing the
Read/Write signal and ¢2. The Read/Write-Prime signal
assures that data will always be read or written while the
data bus in enabled and not during a period of invalid data.
V
~
~i
D DATA
BYTE
TRANSFER
IFC CONTROL
ATN
~I
SRQ GENERAL
REN IIITERFACE
EO I I MANAGE~ENT
l
11
DEVICE A
• ... rl ' II ' II . ...
DEVICE 8 DEVICE C DEVICE D
- TALK
- LISTEN
- TALK
- Lr STEN
--- - TALK
- CONTROL --- - LISTEN
--- ---
---
EX: MPU EX: DMM EX: SIGNAL EX: COUNTER
GEN,
The basic bus connects to devices that can do one or more of the
following:
1. control other units - controller
2. take information from the controlling unit - listener
3. give information to the controlling unit - talker.
The bus consists of eight bidirectional data lines, three byte-transfer
control lines, and five general control lines.
The eight data lines will carry: device commands (only 7 bits used),
address and data (8 bits).
338
BUS STANDARDS
339
~ ~
(')
,0
SECOND DATA BYTE
D 101-8
0
""0
(COMPOSITE)- - - ,0
g
m
H ~
-·
~
.
(IQ
DAV
23 0
,0
z
~
L-
H- rri
,0
t
00 NRFD
n►
=
=
SIO
Q.
t.
H
z
G')
--f
{ll m
=- NDA.C (')
!- L NONE ACCEPTED
:I:
z
D
~ SOME
...=a IIII. ! I 111 I I I l I
.ACCEPTED
! !
C
rn
(IQ
h T1 To T1
Jvs
T2
STRS j T3 T,e
!
I I-
~ ~
T5T6
SGNS ~ t
T7 Ta T9 T10 T1 l
ACRS ~ ANRS _ .
ANRS~~
-~ll
--i~
i ACCEPTOR HANDSHAKE FUNCTION
I ACTIVE STATE SEQUENCE
BUS STANDARDS
DATA BUS
, - - - - - - - ~ I - - + - - - - - - ATN
, - - - - - - - ~ 1--++-----+-EOI
SOURCE
,.-----,
TALK ' LISTEN ;
HANDSH~KE 'L. - - _._J'
DEVICE
DATA
LAST
BYTE
INDICATOR
1------------ ATN
.----------EOI
-------+-
------- IBYTE
XFER
r---,
DEV, DATA
ACCEPTOR
I I
I TALK HANDSHAKE
I I
1..--- J
signals. When the transfer is finished, the EOl line may be used to in-
dicate the end of the block.
The "listen" example works similarly. The controller sends the ad-
dress via the data bus, using the ATN line as before. In this case, the
command sent next is for the device to listen to a talker. The transfer
of data, byte by byte, is then begun using the data bus, and handshake
signals. The EOI then indicates that the transfer is complete.
In summary, the IEEE-488 bus represents quite an advancement in
intelligent data acquisition systems. As more manufacturers produce
compatible equipment, the standard will become even more wide-
spread. In fact, the Commodore:Wusiness-Machines' home microcom-
puter system is equipped with an IEEE-488 bus interface.This may in-
341
MICROPROCESSOR INTERFACING TECHNIQUES
I I I I I I I I
V
DEVICE
N
CONTROLLER
<,... t> D ATA BUS
DEVICE
,r
TALKER
""'
-
DATA BYTE
c:::_ > TRANSFER
coNTROL
(HANDSHAKE)
)
V
( .......
-- I/
-
6800
- - -~
i's..
MC68488 MC3448A
GPIA BIDIRECTIONAL
TRANSCEIVERS
342
ADDRESS 1 MC8T97
SWITCHES BUS 02
XTAL
CJ MCEll75
T/Rl,2 RESET
CLOCK
4.MC3448A
,
IEEE
488.1975 01 02
BUS
SYSTEM DATA BUS DO 7
68488
MC6800 RESET
MPU
SYSTEM ADDRESS BUS AO 15
....
9"
t':'
MC68488
GPIA
R/W
IRO
f ADDRESS
DECODE
LOGIC IRO
==
C')
s
R/W
RESET
02
I
f 6830
ROM
RAM
6810
6850
ACIA RS232C to
C
(/)
~
z
0
►
,c
~
0
e (/'I
MICROPROCESSOR INTERFACING TECHNIQUES
344
BUS STANDARDS
ADDRESS MAP
Hexadecimal Address MC68488 Registers (R/W)
345
MICROPROCESSOR INTERFACING TECHNIQUES
It was developed for the nuclear industry, and all domains of the
CAMAC standard contain rigorous specifications. CAMAC systems
are required to be built to quite exacting standards.
Physical Dimensions
Fig. 6-14 illustrates a CAMAC "crate." The crate is the basic system
sub-unit. It contains a controller and up to 24 peripheral interfaces.
The size of each card, and the connector types, are all specified.
Power Supply
The power supply is a four-voltage type, supplying regulated ± 6
and ± 24 volts. Stability, regulation, and transient suppression are all
covered in the standard. Remember that the power supply, while often
ignored, is the basic most important unit in any system. Any flaws in
the power supply will show up everywhere else in the system. Thus,
CAMAC does something no other standard does: it guarantees the
user that the power supply will be the least of all problems in the
system. Fig. 6-15 illustrates the crate and power supply. (Pictures are
courtesy of Lawrence Berkeley Laboratory.)
Dataway
The CAMAC Dataway bus consists of the following lines: three
control, five command, five address, twenty-four read, twenty-four
write, two timing, and four status. The lines are described in Fig.
6-16.
The three controls are: initialize, inhibit and clear. These signals are
used to put all devices on the dataway into a known state.
The Jive command lines determine the function to be performed.
The 32 possible functions are all defined in the standard. Some func-
tions are for read, write, and status transfers. Others are either re-
served for future use, or not defined.
The 24 read and write lines form the data bus. If extra address
information is required, the data buses may be used to load further
address information. 24 bits allow for simultaneous transfer of three
8-bit bytes for efficient operation. Since some CAMAC systems con-
tain microprocessors, these 24 lines could carry the address and data
from the microprocessor. Since data transfers may occur as fast as 106
per second, this bus has a greater bandwidth than the other buses so
far described.
346
BUS STANDARDS
.;Jf!Ji!i:;:!)ii!/W~·
'"''•\••
347
MICROPROCESSOR INTERFACING TECHNIQUES
348
BUS STANDARDS
\\\\)\
, .'~: ·.;'
; ! ~ ;: : ·
·:!!:!
.. ~·..
!:!;:
;1;~;1~~
349
MICROPROCESSOR INTERFACING TECHNIQUES
350
BUS STANDARDS
SERIAL STANDARDS
Serial transmission requires only one or two wires to carry all
necessary signals between modules or systems. In order to transmit ad-
dress, data, and control, they must be sent bit by bit.
Described here are the RS232C, RS422 and 423, asynchronous and
synchronous communication standards. In addition, data standards
such as ASCII and SDLC will be covered.
EIA-RS232C
• GROUND
• XMITDATA (TO COM EQUIPMENT)
• RECDATA (FROMCOM)
• REQUEST TO SENT (TO COM)
- CLEAR TO SEND (FROM COM)
- DATASETREADY (FROMCOM)
- DATA SET READY (FROM COM)
• DATA TERMINAL READY (TO COM)
• RING INDICATOR {FROM COM)
· RECEIVED LINE SIGNAL DETECTOR (FROM COM)
• SIGNAL QUALITY DETECTOR (FROM COM)
• DATARATESELECTOR (TOCOM)
• DATARATESELECTOR (FROMCOM)
• TRANSMITTER TIMING (TO COM)
- TRANSMITTER TIMING (FROM COM)
• RECEIVER TIMING (FROM COM)
The secondary lines provide the data and control paths for a second
serial channel running at a much lower speed than the primary chan-
nel. The second channel is then identical to the first, except for speed.
The second channel is hardly ever used, but when it is it contains con-
trol information for the modems connected at each end of the commu-
nications line.
351
MICROPROCESSOR INTERFACING TECHNIQUES
The main signal lines are transmit data and receive data. These lines
are used to send serial information between the two systems. The bit
rate may be any one of the following standard rates:
19,200 1,200 110
9,600 600 75
4,800 300 50
2,400 150
Other rates are also occasionally used. The teletypewriter terminals
run at 110, 150, or 300 bits/second. CRT terminals typically use any
of the speeds above 1,200.
Quite often, serial data are transmitted over telephone voice-grade
lines. The data must first be modulated, so that they may be transmit-
ted. For bit rates of less than 300, the method of modulation is known
as FSK: frequency-shift-keying. The "marking" or logic "l" condi-
tion is represented by a tone of given frequency, and the "spacing" or
logic "O" condition is represented by a second, different, frequency.
Bit rates above 300 must use phase-modulation techniques, due to the
lack of available bandwidth. Quite often·, voice-grade lines are too
noisy for high-rate communications. More expensive data-grade lines
must be used.
The other signals are used to indicate the status of the modulator-
demodulator (modem) communications link. Signals such as:
"request-to-send," "clear-to-send," "data-set-ready," "data-
terminal-ready," are used to control the modem link.
The timing in Fig. 6-18 is meant to show a typical communications
transaction. Note how the signals between the modem (communica-
tions equipment) and the computer (or terminal) implement a similar
kind of handshake to that used in most buses-especially the
IEEE-488. The difference, in this case, is that the handshake is used
only at the beginning, and end, of a block of serial data.
RS232C is popular, as almost all dial-up time-share systems use this
standard in their communication subsystems. A similar standard is
current loop. This is used in the mechanical teletypewriters. A good
thing to do is to convert all loop devices to EIA-RS232C via a loop-to-
EIA converter. In this way, all communications become standardized.
A loop-to-EIA converter for a teletype is shown in Fig. 6-19. Also
useful is what is known as auto loop back, shown in Fig. 6-20. This is
where the computer, terminal, or modem, does not have the full stan-
dard imple.mented. The jumpers specified will usually allow the
devices to believe that all conditions are "OK" for data to pass.
352
BUS STANDARDS
CALL
RECEIVED
RING _, 51 ms 1--
INOICATOR'cis( Mtn ;..,- - - - - - - - - - - - - - - - - - - - - - - - - - - -
RING I
INOICATOR~---------------------------
ORIGINATE I
MODE
l WffffffeM
ANSWER
DATA TERMINA
REAOY
..;:L:.,__ _ _ --+-----------------------------
-I
.I
TRANSMITTER
CARRIER _ _ _ _. . , ~
CONTIN S
ms----f--l270Hz,300ms I
•• SPACE-1070Hz -
~'i~~ l27!)Hz 0.3ESS
. Olll.5ELS
THRESHOLD _ _ _ _ _ _ _ _ _ _ _....,;.;....,,..,;;...--.-~-.-,-;;..,--,-r+,_,;;-r-r-r,~-r'T"'"T""'T"'"
_ __
DETECT
ClfARTO
~NO ----------i;=:=::::,450m~;;;:.:;t:=:==:.i-1 I I ,
I
~rf{MARK I twH/t¼@NC!AMPEDW/U,/4:J
DATA SPACE------------------+1---~""'""'"""".....,....,.-_..._....._....,..,...,..
TRANS-{MARK -· ----------------,,,77'1='-'!'T'!ll'r.SJ:"'7"' r--
o~VA SPACE------------1L-~-:±-f....,.,,,.,,--fl¼ic.0i:.::.:0:;.:.N~c::::1AM..::...PE-=:a.6.,._¼"'~'i---------'
'4150m~lso;.;;3 ~
TTY
LOOP
+ ◊>-------• + -l5V
KEYBOARD
- ◊,_____ _ _ ~j ,-.3K
3.3k
vv.------J-.-. TO COMPUTER
-15V
ANSWER
~·~-'~
fl
PRINTERV--VV---
lOK
FROM COMPUTER
-15V-:- -:-
353
MICROPROCESSOR INTERFACING TECHNIQUES
GROUND
7-t------------------------+- 7
2-+----------- 2
3-t------------'"----------~
XMIT RCV
3
4 MODEM
COMPUTER 9
OR
8 5
TERMINA
6 6
8 RS232C LINK 8
354
BUS STANDARDS
ASYNCHRONOUS COMMUNICATION
When data are sent in bursts of equal duration, without clock infor-
mation, they are being sent asynchronously, without a clock. When
data are sent with synchronizing character codes imbedded within the
blocks, they are being sent synchronously: with a clock.
TTL,
[> !:
f,
12VOLTS
TTL
IRS422·
'TTL,
[> J
~
TTL
1 l-
- MC14 MC -
NO COMMON GROUND
(UNBALANCED DIFFERENTIAL
TRANSMISSION)
RS423
T1'L TTL
(BALANCED LINE)
355
MICROPROCESSOR INTERFACING TECHNIQUES
STOP l STCP2
MARK- - - - - -
SPACE _ _ _ _ l 2 3 4 5 6 7 8
I 1.58 MSB
I
9,09 MS --+-I
I
I
DATAREADY --+----------
EBCDIC is similar except that the 128 codes are encoded different-
ly. Simple code-conversion ROMs can convert ASCII to EBCDIC,
and EBCDIC to ASCII. Such an ROM has 8 inputs: seven address
lines for the data input, and one address line to specify the conversion
(either ASCII to EBCDIC or EBCDIC to ASCII). It has seven outputs
for the converted character. The size of this ROM would be 256 bytes
by 7 bits/byte. This is a small ROM by today's standards, and it is
relatively inexpensive to program or purchase.
Who uses EBCDIC? IBM. Who uses ASCII? Practically everyone
else. Other codes exist, such as the five-bit Baudot code (obsolete to-
day), which can also be converted by a look-up ROM.
Naturally, a program may also be used to convert from one code to
another.
356
BUS STANDARDS
BIT NUMBERS
0 0 0 0 l l l l
0 0 l 1 0 0 l l
l' 0 l 0 l 0 l 0 l
h
b7 b6 b5 b11 b3 b2 bl
♦
'' t
'' ♦ g 0 l 2 3 5 6 7
-
0 0 0 0 0 NUL DLI!! SP 0
• p
'
a
p
0 0 0 l l SOH DCl ! l A Q q
0
l
l
0
0
0
l
4
5
EOT
ENQ
DC4
NAK
•
s
~
5
D
I!!
T
u
d
e
t
u
0 1 l 0 6 ACK SYN
•, ...... 6 p V r V
0 l 1 1 7 BEL ETB 7 0 w g
"
l 0 0 0 8 BS CAN ( 8 H X h X
l 0 0 l 9 HT EM ) 9 I y 1 y
l 0 l 0 10 LI' SUB • : J z J ,:
l 0 l l 11 VT ESC ♦ ; K ( k I
l l 0 0 12 l'P PS . < L \ l .'
1 l 0 1 I3 CR as - - M ) m I
l
l
l
l
l
1
0
l
14
15
so
SI
RS
us I
>
?
N
0
A
0
n
0
-
DEL
SYNCHRONOUS COMMUNICATION
357
MICROPROCESSOR INTERFACING TECHNIQUES
ACK Acknowledge
BEL Bell
BS Backspace
CAN Cancel
CR Carriage return
DCI Direct control I
DC2 Direct control 2
DC3 Direct control 3 ·
DC4 Direct control 4
DEL Delete
DLE Data link escape
EM End of medium
ENQ Enquiry
EOT . End of transmission
ESC Escape
ETB End transmission block
ETX End text
FF Form feed
FS Form separator
GS Group separator
HT Horizontal tab
LF Line feed
NAK Negative acknowledge
NUL Null
RS Record separator
SI Shift in
so Shift out
SOH Start of heading
SP Space
STX Start text
SUB Substitute
SYN Synchronous idle
us Unit separator
VT Vertical tab
358
BUS STANDARDS
~~~ ~~ ~
H
DECIMAL
0
D
2D
T
DECIMAL
SA $
T
DECIMAL
88 h
I~
I
t:SO
H
TD
E3 I
8
T
1 2E 58 * 89 i B7 E4 u
2 2F SC ) 8A . 88 ES V
3 30 SD I
8B B9 E6 w
4 31 SE BC BA E7 X
5 32 SF 8D BB EB y
6 33 60 BE BC E9 z
7 34 61 SF BO EA
8 35 62 90 BE EB
9 36 63 91 j BF EC
A 37 64 92 k co ED
B 38 65 93 I Cl A EF
C 39 66 94 m C2 B FO 0
D 3A 67 95 n C3 C Fl
E
F
3B
3C
68
69
96
97
0
p
C4
cs
D
E
F2
F3
'
2
3
10 3D 6A 98 C6 F F4 4
11 3E 68 99 Cl G F5 5
12 3F 6C % 9A ca H F6 6
13 40 BLANK
41
6D - 9B C9 I F7 7
14 6E 9C CA F8 8
15 42 6F ? 9D CB F9 9
16 43 70 9E cc · FA
17 44 71 9F CD FB
18 45 72 AO CE FC ·
19 46 73 Al CF FD
lA 47 74 A2 s DO FE
lB 48 75 A3 t Dl J FF
lC 49 76 A4 u D2 K
lD 4A 77 AS V D3 L
lE 4B 78 A6 . w D4 M
lF 4C 79 A7 X D5 N
20 4D ( 7A : AB y D6 0
21 4E + 7B # A9 z D7 p
22 4F 7C @ AA D8 Q
23 50 & 7D . I AB D9 R
24 51 7E -- AC DA
25 52 7F " AD DB
26 53 80 AE DC
27 54 81 a AF DD
28 55 82 b BO DE
29 56 83 C Bl DF
2A 57 84 d B2 EO
2B 58 85 e B3 El
2C 59 86 f
g
B4 E2 s
87 85
359
MICROPROCESSOR INTERFACING TECHNIQUES
,
REC 0 CHECK ENO
CHARS CHARS OF REC
- PREAMBLE - - POSTAMBLE:
360
BUS STANDARDS
Parity
361
MICROPROCESSOR INTERFACING TECHNIQUES
A checksum can be generated by adding all the bytes in the block to-
gether using add-with-carry instructions. One eight-bit number is then
"related" to information in the block. Another way is to exclusive OR
every byte together. The resulting byte is actually the parity across the
block rather than the parity of the byte. The more checksum informa-
tion, the more accurate the error detection.
Cyclic Redundancy
This is explained in the floppy disk section, and the reader is re-
f erred to Chapter 4. Besides the algorithm presented for the floppy
disk data format, other cyclic redundancy check algorithms are also
used.
Hamming Code
By adding redundancy to our stored byte, one can not only detect
but also correct single-bit errors.
Using eight bits for our byte, one must add (log2 8) + I bits to the
byte for hamming bits. That implies using a twelve-bit word for eight
bits of data. The four extra bits will be parity bits for different
subgroups of the eight original bits.
t
'
h0 hl
parity for column
b0 bl b2 b3 b4 b5 b6 b7 = byte
h0 h 1 h2 h3 = hamming bits
362
BUS STANDARDS
bO bO 10 parity across
bl bl II the block
9 ..........
bits
b7 b7
pO pl pn 18
BLOCK
parity down
the block
A CASE-STUDY:
INEXPENSIVE ANALOG BOARD FOR S100 BUS
363
~
i +5
n
~
,,
0
~
DATA BUS
8212 MCl408
8 BIT
R
m
X _QJ..II DIA
KNOWN ~
-· 0
VOLTAGE
~ 'OUTPUT
>----, BIT 7 of DATA BUS ~
.
(IQ
100m,
(DAI
0, IOV z
Q'I PWR NANO ---i
m
..~
QC
SlllJT I 11
GAIN XHlOO AMPLIFIER Al
"Tl
)>
00
.
()
=
~
= ~
LO L EVEL "") ~
z
G'>
> §:: DECODER tOK
INPUT
OU TPUT ---i .
't::,
"'
0- 74LS138
0- +5V
~
::r
,ov
t::, 0- 0,
UNKNOWN VOLTAGE
z
~
'> PDBIN .~
INPUT
IA/0I
0
C
=
SINP m
10K
..=
(fl
0 COMPARATOR
INPUT
=- PROTECTION
+BV ~ TO ALL 5V
=t=,~ t,
BUS STANDARDS
The Hardware
The output data bus, which performs all data transfers to memory
or output ports, is connected to an 8212 latch. Each bit is loaded by an
input of the latch. Each input represents ½ of a low-power-Schottky
input load.
The 74LS138 decoder, along with the 74LS10 and 74LS04, decodes
the output to port "F8" (hexadecimal). The address is partially de-
coded by ½ of the 74LS10, so that bits A7, A6, AS must all be l's to
enable the 74LS138 decoder. Then the bits AO, Al, A2, A3, and A4
are decoded by the 74LS138. The first output represents "F0" on the
low eight address bits. This enables one of the chip selects on the 8212
latch.
The other chip select is driven by the condition PWR false and
SOUT true. This is done by inverting PWR and "NANDing" it with
SOUT. The output of the NAND is passed through an inverter to the
second chip select of the 8212.
This way, the output data bus is latched into the 8212 latch when the
address is "F0", and the control signals indicate an output instruction
is being executed. The timing is shown in Fig. 6-29.
The latched data is sent to a MC 1408 digital-to-analog converter. At
the output of the converter, a current proportional to the binary input
is present. In order to convert it to a voltage, a current-to-voltage con-
verter circuit is used. It is implemented with ¼ of the LM324 quad op-
amp.
The output is now a voltage between 0 and 10 volts for inputs be-
tween "00" and "FF" (hexadecimal). The next op-amp, in the
LM324, is used to buffer the output so that an output may be driven
without affecting the comparator section.
The third op-amp is used as a comparator for the analog-to-digital
conversion. The op-amp compares the unknown input with the output
of the D/A. If the unknown signal is too small, a variable-gain ampli-
fier , implemented with the fourth op-amp, is used to boost the signal.
Note the protection diodes, that are used so that no damage will be
caused to the inputs, as long as voltage transients there are kept below
100 volts.
The output of the comparator is clamped to TTL levels by the resis-
tor-diode combination, so the 74LS125 tri-state driver can be driven.
The driver is enabled by an input command and the address "F9"
(hexadecimal). The decoding is done similarly to that of the output
port, except that the second output of the 74LS138 is used to decode
365
MICROPROCESSOR INTERFACING TECHNIQUES
... ,, ,, ,,
..,,,""1
T1 ':1 '• T1 T, '3
.---1 \. l - - - - -
ONE
J.
tJ - -
FLOATING - -,
-, \,
TWO ACCUMULAIOII~
\, - J
-' \ I \ I
I
I \
I
OBIN
.. ,.. I \ I \ I L
11£ADY
"O"
WAIT
"I"
wii
$TANS
INFOIIMATION 0 ~@ ~@
01
02
SYNC
D~N +----I-_,
STATUS
INFOAMATION
0 0 0
366
BUS STANDARDS
the address "Fl." In addition, the control lines PDBIN and SINP are
"ANDed" with the address, to enable the driver to bit 7 of the data
bus.
By driving bit 7, we can input from port "Fl", rotate bit 7 into the
carry bit, and test the carry to see if we are above, or below, the
unknown input voltage. Outputting a new value to port "F0" and
checking bit 7 again will form the basis of our analog-to-digital con-
verter. Timing for an input operation appears in Fig. 6-30
Power is supplied by the + 5-volt voltage regulator for all Vee pins
and the Zener diode regulators for the + and - 15-volt voltages, re-
quired for the op-amp package.
Note that three of the bus drivers were used as inverters.
Fig. 6-31 shows how this is done.
+sv
OUTPUT
240
INPUT
When the input is low, the driver is enabled, and the output will be
pulled up to a logic ''I''. When the input is high, the driver is disabled,
and the 240-ohm resistor pulls the output to a logic "0". We could
have used a hex inverter for these functions, but it would have in-
creased the part count.
The Software
367
MICROPROCESSOR INTERFACING TECHNIQUES
Vout convert
10 - 3
= Numio • Bin2
39.0625 X to
binary
or
2.5
= 64,o ► 01()() 00002
39.0625 X 101
1
· ½ = f max
conversion
or
· ½ = 250 KHz
20 X 10-6
Analog-to-Digital Conversion
To perform the AID conversion, we need to implement the suc-
cessive approximation algorithm in software. Another technique
which can be used is the counter-conversion technique. Both will be
discussed.
368
BUS STANDARDS
CALLCONV:
OUTPUT TO DAC
NO INPUT SENSE
DONE (RET)
OR GUESS
WITH MASK NO LAST
LAST GUESS
TOO SMALL YES GUESS TOO
BIG
DRIV. OLD BIT MASK
AND
WITH GUESS
369
MICROPROCESSOR INTERFACING TECHNIQUES
1
· ½ = f max
conversion time
·½=1316HZ
380 X 10-6
This means our converter can just barely go fast enough to digitize
speech.
POWER SUPPLIES
Now that the circuitry is connected, where are the + 5.0 volts ( ±
5%) at 10 amperes? Power supplies, which are at the heart of any
system, are often the most overlooked element of a system. If the
power supply is not properly specified, the system does not have even
a chance of working reliably.
Power-supply performance is measured simply by the following
parameters:
- voltage current ratings
- regulation
- efficiency.
The design of a power supply would take another book this size to
describe. Power..,supply engineering is actually a much harder skill to
learn than digital-circuit design or programming. There are a number
of good references for power-supply design listed at the end of this
chapter.
370
BUS STANDARDS
371
MICROPROCESSOR INTERFACING TECHNIQUES
Regulation
Power supplies are not perfect. They cannot deliver exactly 5.000
volts under all load conditions. This is why they are also rated as to the
ability to regulate, or hold the output voltage current.
Specifications are divided into load-regulation tolerance, and load-
no-load regulation tolerance. Also important is the turn-on overshoot,
and stability under varying load conditions.
If the load is constant, and our input line voltage from the wall
socket is whatever range of values the utility company will allow, the
variation in output voltage over temperature and time is the load-
regulation tolerance.
For example, if our system is an 8048 single-chip microcomputer,
one requires a load regulation of ±50Jo: 4.75 to 5.25 volts in the range
of guaranteed operation. The power supply should typically be two
times better than this if one wishes to be safe. By not choosing careful-
ly, one may operate the system right at the limit of the guaranteed
operating range, and this situation combined with other marginal cir-
cuit factors, such as loading of the buses, temperature, and clock fre-
quency, may cause the system to never work!
If the load varies, one would like to know how much the voltage will
change. This is known as the no-load, load regulation measurement,
6r the step-load measurement. As an example, if one takes a 5-volts-
at-5-amperes supply and attaches a 1-ohm load, the supply should
deliver 5 volts at 5 amperes. If one measures the voltage under this con-
dition, and then disconnects the load and measures again, one should
see optimally no change. In reality, step-load tolerance of less than
½OJo is usual.
In addition to the tolerance, the overshoot and stability measure-
372
BUS STANDARDS
Efficiency
The question always asked is: "Should I build or buy?" First buy-
ing will be examined. The best units are those known as OEM or
Original Equipment Manufacturers supplies. These are commercial
units that are used by most companies in their products. They are ex-
pensive, typically $50.00 for a 35-watt supply, or 5 volts at 7 amperes.
The advantage of an OEM supply is that the user is receiving the result
of hundreds of thousands of dollars in power-supply engineering. The
heart of a system will be a healthy one. The general rule for costs is
about $1.50 for every watt required.
If one builds the supply, there are many design choices to be made.
The transformer, diodes, and capacitors must all be chosen by certain
design rules and formulas. The regulator itself must then be matched
to the transformer, diode, capacitor combination so that stability and
373
MICROPROCESSOR INTERFACING TECHNIQUES
374
BUS STANDARDS
375
MICROPROCESSOR INTERFACING TECHNIQUES
SUMMARY
We have designed an analog data collection and control board. It
was designed to be connected to the SIOO bus. Software was written to
use the features of this DIA and AID converter.
The buses and standards described are intended to make the job of
interfacing easier. To plug the device into a system with no extra work
is every interface designer's dream. We have seen how the many users
of the SIOO, CAMAC, IEEE-488 and EIA-RS232C standards create a
large need for standard-compatible devices, modules, and systems. If
at all possible, stay within a standard. The design will be easier and
your time may be spent on the harder problems.
Parallel and serial bus standards, methods of communication be-
tween modules, and an actual bus interface example were presented.
The SlOO bus is the most popular parallel bus used now, with over 600
different types of compatible boards being produced. The serial
RS232C standard is the most popular standard for data communica-
tions, and versions of data formatting are used, with modems, to
.store and retrieve data from cassettes and cartridges, as described in
Chapter 4.
Power supplies are the heart of a system. Regulation, stability, and
some design parameters have been discussed. The OEM solution is ob-
viously one of the best, as the power supply manufacturer is a
specialist in regular and custom supply requirements.
376
7
THE MULTIPLEXER
A CASE STUDY
INTRODUCTION
DATA BUFFERS
CORE OR RAM
t
1llE MULllPLEXEIJ
Al/10-RESTART
POWER FAIL
N-CHANNEL
TERMINAL
SERIAL INTERFACE
•••
USER
TERMINALS
377
MICROPROCESSOR INTERFACING TECHNIQUES
Designed for a PDP 11/70, the system is also applicable, with only
code changes in the host machine, to almost any host computer. The
cost of providing this function is $50 per channel, as compared to
usually around $250 per channel. The system is also cost-effective in
clusters of fewer than 32 terminals.
The system uses the 8080 microprocessor, 8251 USRT, 8259 inter-
rupt controller, and other components in the 8080 family. The system
has no modem-control features, as it was intended to be at the site of
the terminals, saving even more money in man-hours of time and cost
of wire for connection. This does not even include the cost benefit of
fewer telephone lines and modems.
THE SPECIFICATIONS
The task of connecting a large number of terminals to a time-
sharing facility always presents the engineer with a number of pro-
blems. Most have to do with the interconnection headaches of
modems, telephone wiring, patchboards for testing, and internal
machine interfacing.
Remotely-located concentrators would eliminate many problems.
The new problem: cost. The design goal here is to service 32 terminals
at an input rate never exceeding 30 characters-per-second, and an out-
put rate as fast as possible. Given that the 8080A could execute
roughly 300 instructions in the time between characters at 9600 baud,
if it were to service 32 terminals on input, it would have to have fewer
than 300 instructions in the polling loop for the terminals. Any time
left over would be used for output. The code would have to be thought
out byte-by-byte, with all coding being carefully optimized. A proto-
type was built, under the assumption that it could service at least 16
terminals in a degraded mode.
The typical statistics of our input was a maximum of 150 baud for
any second, and a rate of 50 baud for all 32 terminals combined.
Thus, when completed, the multiplexer could handle a maximum of
150 baud on all 32 at once, or a maximum of 300 baud on one. The
output was a minimum of 300 baud for all 32 at once, and typical 6000
baud when there was a specific demand from a single user.
ARCHITECTURE
The architectural block diagram is presented in Fig. 7-1. Each ter-
minal has its own USART, because each needs a dedicated serial inter-
378
CASE STUDY: A 32 CHANNEL MULTIPLEXER
face. The USARTs are grouped into fours and then placed onto cards,
which are on the 8080A system bus. There are 8,192 bytes of RAM for
data storage, and 1,024 bytes of EAROM for program, in the system.
Lastly, there is an interrupt controller and high-speed-channel card,
which is on the bus.
Each terminal, through its USART, has a 128-character buffer
associated with it, for buffering output to the terminal. This takes
4,096 bytes of the available RAM. The terminals-to-host queue is 256
characters long. These lengths were chosen to optimize the communi-
cation-channel transfers. The method will not be discussed here.
8080A BUS
·DATA
· ADDRESS
·CONTitOL
SOFTWARE
A flowchart of the software appears in Figs. 7-2, 7-3, 7-4 and 7-5.
The software can be divided into four parts: the initialization routine,
379
MICROPROCESSOR INTERFACING TECHNIQUES
the polling routine, the interrupt routine to fill terminal buffers from
the host, and the interrupt routine to empty the terminal-to-host
waiting queue.
The initialization runs only when reset, then the latter processes
may run, one at a time. They communicate only through the output
data buffers and share no other common memory space, other than
pointer tables.
The initialization routine clears all memory, sets up tables, finds
which boards are plugged in, resets all USARTs, and will print out er-
rors, if a debug board is installed. This is roughly all the system
housekeeping. It sets the stack pointer, resets and sets the mode,
speed, and number of bits-per-word on the USARTs. This section of
the program is 60% of the code used for the whole application.
PROCESS0
BUFFER TO CHANNEL
FULL INTERUPT
ROUTINE
TOTAL 8080A BYTES FOR PROGRAM: 526 BYTES! LESS THAN ¼ OF THE 2708 USED
380
CASE STUDY: A 32 CHANNEL MULTIPLEXER
INITIALIZATION
USART MODES
BOARDS UNPLUGGED
SELF TEST AND
MEMORY CLEAR
GO TO FIRST BOARD
POLLING
CHECK STATUS OF
BOARD
CHECK FIRST
BUFFER FOR
CHARACTERS TO
TERMINALS
EMPTY TERMINAL TO
HOST QUEUE BY ONE
CHARACTER IF FULL
(PRIME QUEUE)
FETCH CHARACTER
WAITING IN HOST
USART
- ~LACE.IN lAST
BUFFER POINTED UPDATE LAST
BUFFER POINTER
TO
381
MICROPROCESSOR INTERFACING TECHNIQUES
YES
RETURN
NO
EMPTY QUEUE BY
ONE CHARACTER
RETURN I
The polling routine goes through the list set up by the initia1ization
program, testing to see if there has been a character typed by a ter-
minal, or if there is data in a buffer, to be output to a terminal. Thus,
each of the 32 terminals is serviced once during each pass. If the
channel-to-host is busy (it takes 1 millisecond to transmit a character
at 9600 baud), the characters are put into a waiting queue that will be
serviced when the "channel-not-busy" interrupt comes in. If the chan-
nel is not busy, the waiting queue is emptied by one character, and the
character currently waiting is placed at the end of the line, in the
queue. In this way, the queue-service routine is primed and will con-
tinue to interrupt, when not busy, to empty all the characters waiting
for the channel. The format used for data transmission is the follow-
ing: the tag for that terminal is sent first, and then the character is sent
to the host, via the queue routine. Each board has its own priority
382
CASE STUDY: A 32 CHANNEL MULTIPLEXER
table, so that only one input is processed, per pass, per board. After a
character is transmitted, or, if a board has no characters, the buffer
area for each terminal is then checked to find if there is an output
character pending (these are placed in the buffer by the host-interrupt
routine). If so, the buffer gives its character to the USART to be trans-
mitted, and all the pointers are updated. When there are no incoming
characters, and no buffer is full, the system still polls each board for
input, and each USART buffer for output.
The channel-queue-interrupt routine looks at the queue, and trans-
mits a character, if there is one waiting; otherwise it returns. This rou-
tine will not be called again by interrupt, until the polling routine
primes it by sending a character.
The host-interrupt routine waits for information to come from the
11/70, or host machine, before it executes. When a character is re-
ceived, and ready, an interrupt is generated that then starts this inter-
rupt process. This process checks the incoming character and, if it is
data, places it in the appropriate output buffer area. After this, poll-
ing resumes. Other characters from the host perform status requests,
data-tag-switch, and soft-restart commands.
The host-interrupt routine may interrupt at any time during polling.
It first saves the status vector of the machine, then picks up the char-
acter that caused the interrupt. If the most-significant-bit (MSB) is a
'' 1• ', the character is a tag, or a command. If it is a tag, it is stored, so
that the following data characters are loaded into the buffer pointed
to by the last tag.
The most-significant-bit could also mean that it is a command. The
commands allowed are: "status-request,•• "status-change,•• and
"soft-restart.., "Status-request" will send back a status tag followed
by the status of that USART. "Status-change" will take the next char-
acter, and transfer it to the USART control register. This can be used
to turn ports on or off, and change baud rate by a factor of four.
"Soft-restart" will reinitialize the entire system. Caution is advised in
the use of these controls: do not expect the data buffers to be unaffec-
ted by their use! This is because these commands require more time
than is allowed to poll all the terminals. Thus, interrupts are locked
out and characters may be lost. These commands are usually used to
re-intitialize the system from the host, after the host crashes.
The most-significant-bit being "O" means that the character repre-
sents data. This character is then loaded into the last place in the buf-
fer pointed to by the last tag. All following characters will load into
the same buffer, until a new tag is sent.
383
MICROPROCESSOR INTERFACING TECHNIQUES
INT REQ
SLOW
..:!:2..' - ' READER ADDRESS BUS
FAST WAIT
Al5
Al4
AlO
878J>
+ All 8205
PROM
Al2 DECODE
8080
CPU Al3
□
DATA BUS
SYSTEM
1 - - - - ~ CONTROL f-----..;;,;...,;,...----
8224
CLOCK
CONTROL BUS
The 8080 needs a clock and a system controller. These functions are
provided by the 8224 and the 8228 chips, respectively. The 8224 pro-
vides the necessary timing from the 18-megahertz crystal to drive the
two-phase clock of the 8080. It also provides the reset signal synchro-
nization necessary.
384
CASE STUDY: A 32 CHANNEL MULTIPLEXER
The 8228 system controller provides the system with the control bus
and also buffers the data bus, so that all of the modules in the system
can be driven with no load limitation.
Also on this board are 1,024 bytes of EPROM provided by the
2708. Notice that the selection of this device is fully decoded. The
EPROM will only respond to addresses from "0000" hexadecimal to
"03FF" hexadecimal. This is where the multiplexer program resides.
The selection is done as follows: all address bits AlO through A15
must be low, to enable the EPROM, as well as the MEMR signal. The
first four of those signals, along with this MEMR, go to a l-of-8
decoder, an 8205. If all of these are zero, then the first output is
selected. Then this output is checked with the last two address lines. If
all are zero, then the CS7s held low, selecting the EPROM. The
EPROM bus driver, an 8212, is also enabled at this time to drive the
appropriate cells' data onto the data bus, to be read by the processor.
Bit 0 Bit 7
~
91L02 91L02
••••••
~tj N'EMW
~ 91L02
• •••••
~
91L02
A11 e I e e I I
Al
ADDRESS BUS
DATA eu~
385
MICROPROCESSOR INTERFACING TECHNIQUES
RAM Modules
There are two memory cards in this system. They are both identical,
except one is for addresses "1000" hexadecimal through "1 FFF"
hexadecimal, and the other is for addresses "2000" hexadecimal
through "2FFF" hexadecimal. These two cards provide 8,192 bytes of
RAM storage.
Each card contains 32 static 1,024 x 1-bi t RAM chips, bus drivers
and receivers, and address-selection logic.
A single RAM chip can store 1,024 bits of information. In order to
store 4,096 x 8 bits, we need to organize these chips into a memory
array. Note that we need one chip for each bit, and that we need four
sets for 4,096 bytes.
AO
+5 ----0
GND ---0
Al CE LL ARRAY
ROW
SE LECT 32 ROWS
A2 X
32 COLUMNS
AJ
A4
DI DO
COLUMN 1/0
R/W DATA
CONTROL COLUMN SELECT
cs
A9 AB A7 A6 AS
386
CASE STUDY: A 32 CHANNEL MULTIPLEXER
Since, for any group of 1,024 bytes, eight 91 L02s will need to be
enabled, the chip-selects for each of the groups of eight are tied
together. From there, these four group-selects go to a l-of-8 decoder.
A6 A7
AD
A5 A8 Al
A2 DO
R/W A9
A3
A1 cs A4
A2 DO
A6
A3 DI
DI
Al
A4 +5
AB
AC GND A9
RW cs
DI 0
DO 0
DO 1
DI 2
DO 2
DO 3
cs
DIEN
387
MICROPROCESSOR INTERFACING TECHNIQUES
The data bits-are bussed from each group in the direction perpen-
dicular to the chip select. All bit Os should be tied together, as well as
bit ls, bit 2s, bit 3s, etc. Since 91L02's cannot drive the bus directly,
all input data lines come from an 8216 bidirectional bus driver and
receiver. In a similar fashion, all data outputs from the 91L02s go to
the 8216 bidirectional bus drivers. An illustration of the 8216 appears
in Fig. 7-10.
Two of these devices will provide a standard method of listening to,
and driving, the data bus. The DIEN signal controls whether the bus is
driven by the 8216, or whether the bus is listened to. The CS enables
the outputs to drive both the bus and the DO outputs. If CA is high, all
of the DB and DO pins are in the high-impedance state.
The direction of data-flow is determined by the MEMR signal.
When it is low, the RAM will put data out onto the DI lines of the
8216s. The bus-drivers will be enabled, to drive the 8080 data bus with
this data. At all other times, -the memory array listens to the bus. The
only time it will write data into the memory is when the MEMW signal
goes low and the chips are selected.
The address selection is performed in a way so that the address of
the board may be selected by jumper wires. The low ten address bits
go directly to the 91L02s. The next two bits go to a 1-of-8 decoder
(820S) to select one of the four sets of eight memory chips. The enable
line d'f the 8205 comes from a wire-ANDed combination of exclusive-
or (XOR) gates.
Only when all of the outputs from these four gates are high will the
memory board be enabled. Each XOR gate compares an address bit
with a jumper wired to "l" or "0". If both are identical, the output
will be "0". If they are different, the output will be "I". To set these
jumpers for the right address, we set the jumper to the opposite of
what the high four address bits should be. If we want "0010", for
A15-A12, the jumpers should be tied to "1 ", "1 ", "0", "1 '\ respec-
tively. In this way, the board will respond only when an address lies in
the area of 0010XXXXXXXXXXX2 • This is pages "20" through
"2F" hexadecimal, or "2000" through "2FFF" hexadecimal. Exer-
cise for the alert reader: What should the jumpers be for "1000"
through "JFFF"?
388
CASE STUDY: A 32 CHANNEL MULTIPLEXER
~
w
a:
0
0
<(
Cl)
:::>
I- I-
<( cc
I- 0
r-- Cl) Q.
""
~
v
~
-1' I-
a:
t l
(I')
...
Lt)
N
u
n/ Cl)
:::> co ....
,.... '
t !
..I'...._ I-
a:
...
rv Cl)
:::>
N
Lt)
N
00 -
_,
t !
..J
~ I- ...
0
a:
1- n/
a:
Cl)
:::>
... Lt)
N
00 -_,
2
0
u
t l
~ I- ...
y a:
Cl)
:::>
0 Ln
N
00
--
-- i'
.. '\ (
\ ( \ I\
,.,.,... w V' -
a
:::>
w
I-
Ln <( <(
co a:
~
00
389
MICROPROCESSOR INTERFACING TECHNIQUES
390
CASE STUDY: A 32 CHANNEL MULTIPLEXER
BAUD
RATE
30
9600
4800
2400
1200
600
300
150
110
391
MICROPROCESSOR INTERFACING TECHNIQUES
_ _ _ _ _ _ _ _ _ _...:C:,;;ONffiO...,:;.__ _ _ _ _ _ _ _ _ __
T D
LINES TO
8251 ~ I-OST
Baud Rate
1----1
Generator
RX ROY
TX RDY
POWER
UP
392
CASE STUDY: A 32 CHANNEL MULTIPLEXER
WRITE l/0
WRITE 1/0 F8 32 SETS LOW ADDRESS FOR CALL ]
FOR INT l
WRITE l/0 F7 DO SETS HIGH ADDRESS FOR CALL
WRITE l/0 F8 F2 SETS LOW ADDRESS FOR CALL ] FOR INT7
WRITE l/0 Fl 00 SETS HIGH ADDRESS FOR CALL
WRITE l/0 F7 70 ENABLES ONLY INT 1 AND INT 7
WRITE 1/0 F8 AO SETS ROTATING PRIORITY RESET MODE
0019 C9 RET
0020 ORO 0020H
0020 CDC700 RST4: CALL SND50 ; SOFTWARE RESET
0023 C7 RST 0
393
MICROPROCESSOR INTERFACING TECHNIQUES
394
CASE STUDY: A 32 CHANNEL MULTIPLEXER
, ···•··•·- ......
o ♦ , + ♦ • J• ••- • .;••
'I•• -··•> ..···•· ••-·
> + 4 • 0. • M ♦ ",. 0 • 0
~!!~::~!;~!~~:~
.........
~ ! ! : ~ ~.: t·! : ! : : :
...... ........
....................
._,
.·
,
,
,
, ....... .....
• • .. , ~ .... . . . + •• .
................... _,.,
: ! ~:: : ~: : ~=: ! ! ~
III1ll{
..... , ~· ...... .
::;1t;,:-:~n~::
'.............
)(mil.
.,: ! ~: ~ :: ! ; ! !!!!
..............
···•· ••"'•·····
.. ...............
:.:::. ..::.. .. :::::~:
• • • + •• "' • • ,. • • •
'. .......
.. ...,.
........ ..
. ............ . ~ •• t •
..' ..........
~
• .. • ., l>• • ·· • ..... .
.,
. ................
.~;:~
........,....
, !~~:::t:
..............
.....
..........
............. . ........
,
.... ....
.., .. ......
,
, , ·> . ' • ·. • ~ . . . ~ . . . .. .. .
' , , ~ ~
, ,
' • • +. . . . . . ~ • • • .\ + + ~ .
395
MICROPROCESSOR INTERFACING TECHNIQUES
..,.
:((:;·
396
CASE STUDY: A 32 CHANNEL MULTIPLEXER
397
MICROPROCESSOR INTERFACING TECHNIQUES
CONCLUSION
l. CENTRAL PROCESSOR
2. MAIN MEMORY
3. DISK STORAGE
2
4. TAPE DRIVES
5. COMMUNICATIONS PROCESSOR
3
6. PRINTER
7. REMOTE MULTIPLEXER
4
REMOTE MULTIPLEXER
5 7
COMMUNICATIONS CHANNELS •••
6
398
8
TESTING
INTRODUCTION
What do you do when it doesn't work? What went wrong and why?
The debugging process, also known as testing or trouble-shooting, is
an integral part of any system design. Murphy's Law usually holds: if
anything can go wrong, it will.
When faced with a misbehaving system, there are a number of tech-
niques available to the designer for identifying and correcting pro-
blems. In this chapter, the causes of common problems, and their
solutions, will be presented. Problems such as component failure,
software failure, and noise-induced failure will be analyzed, and
methods for identifying them will be presented.
The tools necessary in order to identify and locate these problems
will also be described: voltmeter, logic probe, signature analyzer, os-
cilloscope, digital analyzer, in-circuit emulator, emulator, and
simulator.
Finally, a case history of the "One Bit in 16,384" will be presented.
The example illustrates the debugging phase in the actual design of the
multiplexer presented in Chapter 7.
399
MICROPROCESSOR INTERFACING TECHNIQUES
Component Failure
Some parts last longer, on the average, than others. Of course, this
table assumes that all parts a,re being used properly. These figures are
400
DIGITAL TROUBLE-SHOOTING
Suppose we made 1000 of these systems, and used them in the speci-
fied environment? After 1000 hours, it would be most probable that
18 would have failed. After 10,000 hours, 180 would have failed.
How often do parts fail? This simple question, which we have an-
swered on an average basis, tells us nothing about the distribution of
failures. It gives the mean. Most components exhibit the following
lifetime characteristics shown in Fig. 8-2.
Most failures occur when new, or when old, and fewer failures oc-
cur in the "middle-age" of the components.
"New" and "old" differ for each component. In-depth analysis of
the entire system involves simple but time-consuming calculations
concerning each component's lifetime failure history.
A "burn-in" test tries to weed out the "infant-mortality" part of
the curve before parts are shipped to the buyer.
The table is accurate only for the environment specified. Commer-
cial, industrial, and military applications all lead to different ways of
measuring the MTBF. A unit designed for a child's toy may last five
401
MICROPROCESSOR INTERFACING TECHNIQUES
%/1000 HR.
FAILURE
l
INFANT
-
LIFE
MIDDLE AGE OLD AGE
Software
402
DIGITAL TROUBLE-SHOOTING
Noise
TRANSFORMER
+5.0VOLTS
l 17VAC ~ OUTPUT
RECTIFIER
403
MICROPROCESSOR INTERFACING TECHNIQUES
~---=--
+S.0VOLT
_,,,,,--10.0 V p-p
~ NOISE AFTER RECTIFIER
j;~O JI Il 0
404
DIGITAL TROUBLE-SHOOTING
We will present here the tools available and the kinds of problems
which can be identified with them. Tools will be examined closely as to
their own limitations.
Fig. 8-6 presents a short summary of problems and tools. The dis-
cussion will follow this table and expand on each problem-what a
tool can do to find it, and how long it would take.
Simple Problems
The VOM
To measure a voltage, the meter is placed in parallel with the circuit
element. Fig. 8-7 shows the measurement of the power-supply voltage
at the output of a regulator. The VOM will easily measure all such vol-
tages, but be warned that it will not detect excessive ripple or noise on
the power supplies.
405
MICROPROCESSOR INTERFACING TECHNIQUES
You have
E411ipment
You can solve
problems like:
VOM PROBES 501'.AIIA. osc. D.D.A. I .C , E. EMU.
TABLE OF ABBREVIATIONS
406
DIGITAL TROUBLE-SHOOTING
+5VOLTS±5%
LOAD
TTL
CIRCUITS,
P, ETC.
Bad Components
Resistors, capacitors, diodes, and transistors can all be checked
against known good devices. They can be measured with the DVM or
VOM to determine whether they are basically functional. Other
special test equipment is needed for diodes and transistors to establish
device characteristics.
Integrated circuits are difficult to test without expensive equipment.
When debugging, several of each device used should be kept in stock,
in order to replace a device with an inherent malfunction. Once the en-
tire circuit is working, all devices in stock should be tested in the
prototype system, to make sure that no marginal problems occur in
production due to component tolerance changes.
407
MICROPROCESSOR INTERFACING TECHNIQUES
Design Problems
You thought you knew what you wanted-but you didn't. Yes, we
all make mistakes, so we might as well admit it. Design errors are di-
vided into two general categories: improper specification and impro-
per use. Examples of each follow.
Improper Use
Passing too much current through a resistor will cause it to burn up.
Applying too much voltage to a capacitor will cause it to short. Every
device has its limits. The "too much" problem is the most common.
For example, too many loads on a single output line may cause the
system to read or write improper data values intermittently, depending
on temperature variation.
Improper Specification
If we believe a part to be able to drive 30 bus loads when it can only
drive 20-this is improper specification. It simply was not noticed in
the data sheet upon specification.
More subtly, the timing of a particular part may be misunderstood.
For example, if the address gated to a memory part must be stable 20
nanoseconds before the data and write pulses, this may have been
overlooked and the system timing design may violate this condition.
Design problems require a full range of equipment for proper
troubleshooting, but a VOM-oscilloscope combination will suffice if
time is of little concern. These problems manifest themselves primarily
in an intermittent fashion in the case of overloading bus lines, and in
burning and smoking parts in the case of overvoltage/current.
The burning parts problems are simple-get a bigger part or im-
prove the design so it will work with the parts you have.
408
TROUBLE-SHOOTING
409
MICROPROCESSOR INTERFACING TECHNIQUES
Logic Probes
DYNAMIC PROBLEMS
In operation, the system doesn't work. The VOM, logic probe, etc.,
will not indicate time. Thus, they are of little use in the dynamic case.
We need devices which will indicate that the logic-level timing is cor-
rect.
The Oscilloscope
410
DIGITAL TROUBLE-SHOOTING
time, no harm will be done; however, the fault will cause problems.
Fig. 8-10 shows a trace for such a condition. Note how the logic "O"
level is not correct.
5V
OV
20mA
1
Jl.f7_~
I I
~ L LOADS
♦ l 6mA
_r--7._ f36mA
411
MICROPROCESSOR INTERFACING TECHNIQUES
412
DIGITAL TROUBLE-SHOOTING
STATE MEASUREMENT
All system timjng and system logic levels are correct when observing
any single bit or line-but we need to observe all the lines at once in
time. We could gather 16 oscilloscopes together (and early analyzers
were simply multi-channel oscilloscopes), but it is not specially
convenient to observe 32 tiny traces on the face of an oscilloscope
tube. For this reason, we developed logic analyzers, or more accurate-
ly, digital-domain analyzers.
RAM
ROM
128 8
PIA 8DATA
16ADDRESS
CLOCK
R/W
INT
VMA
Logic Analyzer
What does a digital-domain analyzer do? It allows us to observe up
to 32.nodes in the system simultaneously. lt will display these bits in
binary, octal, hexadecimal, or in the form of conventional oscillo-
scope traces. It will begin displaying the information when a given
combination of bits, or trigger, occurs. It will store every clock cycle,
or more often a new set of signals, and be able to display a few sets of
signals before and after the trigger set. Each set of signals in time is
known as a state.
Available analyzers fall into two categories: those that emphasize
timing information, and those that emphasize state information.
Timing-oriented analyzers are merely multi-channel oscillocopes.
These devices are useful where logic glitches, noise, or logic-level
problems are suspected.
413
MICROPROCESSOR INTERFACING TECHNIQUES
16AMPS R/W
MSB LSB
I
II
CP2 VMA
MSB
DATA
LSB
X XX X X X X X X XX X X X X X XXX XXXX XXXX
The 1600S was triggered by the interrupt signal. In Fig. 8-14, the
state flow is displayed. The data displayed are:
1. The current instruction cycle is finished. Instruction is an "F2" hex
at location "1385" hex.
2. The status is now pushed onto the stack, before going to the
service-routine vector location. Note the stack is at locations
"3FF" hex downward. The program counter, index register, accu-
mulators, and flags are stored in successive locations in the stack.
3. The microprocessor now fetches the contents of addresses "FFF8"
and "FFF9" hex. The contents are transferred to the program
counter.
4. Interrupt-service routine begins at "1351" hex. Execution contin-
ues from this point.
414
DIGITAL TROUBLE-SHOOTING
.---------CB2
, - - - - - - - - READ/WRITE
, - - - - - - - - VMA
, - - - - - - DATA
ADDRESS
In-Circuit Emulation
415
MICROPROCESSOR INTERFACING TECHNIQUES
Signature Analysis
416
DIGITAL TROUBLE-SHOOTING
A Signature Analyzer
This device relies on the fact that any repetitive sequence of signal
values may be stored in a recirculating shift register, whose value,
clocked into a display each time around, will have a certain value. A
device can be designed so that the probability of two bit streams hav-
ing the same value or "signature" is extremely small.
Thus, each node in a system will have its own signature when it is
working correctly. It will also have a special signature for each possi-
ble problem. By using a fault-tree method, developed by using the
analyzer, all faulty equipment can be debugged quickly, down to a
faulty component.
It will not find initial software problems, or the cause of intermit-
tent failures in a system.
In Fig. 8-18 we see the trouble-shooting flowchart, using a HP
5004A Signature Analyzer. These signatures were generated on a good
instrument and the chart developed to speed repair.
Comparison Testing
419
MICROPROCESSOR INTERFACING TECHNIQUES
START
NO YES
A2S1, A2W2,OAIU57
YES
NO INPUTLATCHAIU51 OR
A1U51
420
DIGITAL TROUBLE-SHOOTING
Self-Diagnostic
421
MICROPROCESSOR INTERFACING TECHNIQUES
Stored-Response
422
DIGITAL TROUBLE-SHOOTING
obtained, in phase two, the system will only run in comparison mode
by executing a specific test program and measuring the response.
This method is used essentially in production, and for incoming
testers. The cost of the system required to provide efficient stored-
response testing, plus the programs, can range from $50,000 to
$500,000.
Fixed-Pa/tern Testing
In a fixed-pattern test, identical, alternating, cyclical patterns are
successively written, then read, at each memory location. This will
detect gross RAM failures. However, this will not detect pattern-sensi-
tivity problems. Pattern sensitivity is a typical source of failure in
high-density chips. Because of the geometrical layout of the chip,
some combination of bits written at some instant of time in memory
cells might cause some other bit position elsewhere in the device to
turn on or off. This problem can happen in RAM memories or in
microprocessors themselves. Whenever this problem occurs in a
microprocessor, it is a basic design failure, and there is not much the
user can do about it. The best that can be done by the user is to run a
worst-case program, supplied by the manufacturer, which has been
shown to make similar units fail because of the specific sequence of
instructions involved. This problem will not be considered here, as it is
deemed highly infrequent once a chip has been in the field for more
than a year. In the case of memory, however, especially in the case of
high-density memory, pattern sensitivity is a frequent_problem, which
can be diagnosed relatively easily using an algorithmic pattern-gener-
ation test. This will be described in the following section.
423
MICROPROCESSOR INTERFACING TECHNIQUES
Galloping-Pattern Testing
The galloping pattern test is usually abbreviated "galpat." The
principle of this technique is to write successive binary values into
memory cells, then compare them to all of the rest of the memory,
before moving on to the next memory location. In this way, if writing
into memory/
cell zero affected the contents of memory cell 102, this
will be detected by the test. In a typical galpat, the memory will be ini-
tialized with a known content, such as all ones or all zeros. The basic
test algorithm is the following:
1. The contents of a location L-1 are tested against the contents of all
other memory locations. They should match.
2. The address L-1 is then incremented by one, and step one is carried
out until all memory locations are tested.
3. The initial data pattern is then complemented, and one goes back to
step one.
Many variations are possible on this basic galpat. They have been
nicknamerl "marching ones and zeros." "walking ones and zeros,"
and "galloping patterns" (galpat one and galpat two).
Ideally, one should write all possible patterns in each memory loca-
tion, and, after writing a pattern in every word, check every other
word of the memory to verify whether it might have been changed. In
addition, after checking each of the other memory words, one should
immediately come back to the original memory location under test in
order to verify that its pattern has not been changed by the tests per-
formed on another memory location. It could happen that the fact of
checking every other memory location would modify the original con-
tents of the memory cell, then modify them again so that eventually
they would have the correct initial contents. A possible failure would
then not be detected if one did not come back every time to verify the
contents of the initial cell. It is easy to see that such exhaustive testing
will require a very high number of operations. A simple memory exer-
ciser, checking a 32 K memory, will typically run for several minutes.
It will, for example, write all zeros, or all ones, or write its own ad-
dress in each memory location, and then rotate these addresses
through the available memory. If the test uses gal pat techniques, it
could easily run for half an hour, or even for several hours. For this
reason, these tests are usually run only during the initial debugging
phase of the system, or when a malfunction is suspected. It is not
practical to consider their use once the microprocessor system is
operational, unless a simplified version is used.
424
DIGITAL TROUBLE-SHOOTING
These two cases will not be detailed. When programs are developed
on a large-scale system, cross programs are used. A cross assembler
will create, for example, 8080 code on an IBM 370. It is necessary to
test the correct execution of the resulting 8080 code. This will be per-
formed with a simulator. An 8080 simulator will be used, which exe-
425
MICROPROCESSOR INTERFACING TECHNIQUES
cutes all the 8080 instructions in simulated time. In this way, the com-
plete logic of the program will be tested. The essential limitation of
such a simulator is the fact that no input-output can be tested unless
the user deposits known data at the right time into selected memory
locations. Input-output registers are then simulated by memory loca-
tions. Unfortunately, the timing of input-output is often random and
almost always complex. For this reason, a simulator is only us·e d to
test the overall logic of a program. This is fine for testing numerical
algorithms, such as a floating-point package. It is inadequate for
debugging a complex input-output interface.
In any system where the user must test real input-output in real
time, one of the most significant aids in testing is the emulation of the
microprocessor itself. This is called "in-circuit emulation."
In-Circuit Emulation
426
DIGITAL TROUBLE-SHOOTING
427
MICROPROCESSOR INTERFACING TECHNIQUES
428
DIGITAL TROUBLE-SHOOTING
HAND-WR! TTEN
PROGRAM KEYBOARD
PROCESSOR 1
LISTING PRINH.R
SOUlCE
l'ROGRAM
TEST-CHANGES---) KEYBOARD
l- ASSEl'IILE:R
,,..,,.~m·• l PRINTER
FRONT PANEL
OBJECT
PllOGRAM
LOADED
REAL J/0 PROGRPM
Slr-l.lLA'Tal
PROMS PROM PROGRAl't1ER DEl!U;GER
El'IJLA'Tal
429
MICROPROCESSOR INTERFACING TECHNIQUES
The address test should result in each of the address bit lines tog-
gling at increasing long time with square waves.
The jump test is so short, that it is usually possible to observe all
lines with an oscilloscope to check all dynamic conditions. Also, all of
the address bits-from bit A2 to bit A 15-should be all zeroes in the
suggested test.
The input-output will allow each input bit to be tested. If the bit is
held high, the corresponding bit on the output should also go high. If
it does not, there is a fault with the input-output scheme in the system,
or the microprocessor.
Now it can get interesting. Try larger programs, working your way
up to the final applications program. At this point, all problems
should be software ones. If you are sure it is hardware-why? Go
back and write different simple test programs to establish whether you
are right or wrong. Remember: if a few instructions work OK, usually
they all work OK.
430
DIGITAL TROUBLE-SHOOTING
Know your buses. As a rule, connect no more than one input and
one output to any bus line. Overlooking this may cause noise-
sensitivity problems due to overloading. The most common line
that violates this rule is the RESET line.
Don't plug it in upside down or skewed down by one pin. Know
which way is up, down, right and left. If in doubt, measure your
circuit at the socket and call the manufacturer to find where pin
one is.
I_
•
HAS THE SYSTEM BUZZ TEST-
BEEN CHECKED FOR ~ CONTINUITY AND
ALL WIRING ERRORS? NO OPEN CHECK
WITHVOM
YES
I
WITHOUT PARTS IN
THE SYSTEM- APPLY
POWER. ARE ALL
~
CHECK POWER VOLT AGES CORREDT
SUPPLIES ON EACH IC?
YES
INSERT COMPONENTS
WITH POWER OFF.
CHECK TWICE THEY
ARE WHERE THEY
YES
POWER OFF
(REPLACE BURNED ,.__ BELONG! POWER ON
IS ANYTHING TOO
OUT PART) WARM? IS THERE SMOKE~
NO
- WIRING ERROR
CHECK ALL BUS LINES - TWO OUTPUTS
FOR PROPER LOGIC
LEVELS. IS THERE
_..
YES
- TIED TOGETHER
-BAD I.C.
A BAD LEVEL? - NOISE PROBLEM*
'
-, NO
-
SOFTWARE BUG IN
TEST PROGRAM
. WIRING ERROR
•
i..-
TRY EXECUTING
SIMPLE SOFTWARE I I
FIX
· DESIGN ERROR
· NOISE PROBLEM'
NO
TEST PROGRAMS-
DO THEY WORK? +
• SOFTWARE BUG
'[IF SO, CORRECT) YES - MISUNDERSTANDIN
· Of COMPONENT
- FUNCTION
~
TRY APPLICATION- - HARDWARE NOISE*
PROGRAM WORK?
YES
"
DONE
431
MICROPROCESSOR INTERFACING TECHNIQUES
432
DIGITAL TROUBLE-SHOOTING
Week 8:
P .C. boards back and debugged. Replaced wire-wrap boards with
P.C. boards, one at a time, to check for errors.
Week 9:
Still fixing wiring errors on P.C. boards. System still acting funny.
Logic analyzer is being used extensively to find the problem.
Week 10:
Bad bus driver on host USART card found. Now only crashes every
day or so. P.C. boards finished. System will sometimes pick up im-
proper data from terminal. In-circuit emulator being used to check the
data pick-up routine on a trace-back basis. Problem only happens
every 8 hours or so-thus, truly difficult to catch.
Week 11:
Argument between programmers and designers-unhealthy finger-
pointing session. Friday the fault is found. Two problems.
Week 12:
There was a bad bit in the EPROM used for the program, and the
carry bit was not cleared upon entering the interrupt routines, where
an add-with-carry instruction was used, instead of an add-with-no-
carry instruction. The instruction determined the location of the data
to be transmitted, hence it would occasionally get the wrong data
upon encountering a carry set after an interrupt. The problem of the
bad bit came by checking the PROM against the listing four times (it
escaped detection that long!). The problem of the wrong instruction
was traced back using the logic analyzer, when it triggered on a read
from the wrong place.
Epilog:
SUMMARY
433
MICROPROCESSOR INTERFACING TECHNIQUES
presented, and examples of each have been given. For reference, all of
the equipment required in a prototyping situation is illustrated in Fig.
8-22. Note the cost: typically $45,<XX>. Use anything less, and the time
required to fix things or find out what is wrong will increase.
___,...........,,. • I.CA.
REMEMBER!
DON'T
434
DIGITAL TROUBLE-SHOOT! NG
435
9
EVOLUTION
TECHNOLOGICAL EVOLUTION
PROGRAMMABLE INTERFACES
COST
The cost of interfaces will probably remain higher than the cost of a
processor, because of higher complexity and lower volume. However,
it has become almost negligible compared to the cost of peripherals.
"PLASTIC SOFTWARE"
As soon as a software algorithm becomes well-defined, it can be
solidified into LSI at low cost. This is "plastic-software": programs
can be purchased as a plastic LSI chip.
In the next step of evolution, it is likely that many of the algorithms
or programs which have been presented throughout this book will be
implemented as part of complex LSI chips. They will have become
plastic software.
Interfacing will then have been essentially reduced to the simple
interconnect of the required chips. When this time comes, it is hoped
. 437
MICROPROCESSOR INTERFACING TECHNIQUES
438
APPENDIX A
MICROPROCESSOR MANUFACTURERS
439
MICROPROCESSOR INTERFACING TECHNIQUES
Mostek Signetics
1215 West Crosby Road 811 East Argues Avenue
Carollton, TX 75006 Sunnyvale, CA 94086
(214) 242-0444 (408) 739-7700
Telex: 30423
RCA Synertek
Box 3200, Rte. 202 3050 Coronado Drive
Sommerville, N.J. 08876 Santa Clara, CA 95051
(201) 685-6000 (408) 984-9800
TWX: (910) 338-0135
440
APPENDIXB
S 100 MANUFACTURERS
441
MICROPROCESSOR INTERFACING TECHNIQUES
442
APPENDIX
443
MICROPROCESSOR INTERFACING TECHNIQUES
444
APPENDIX
445
MICROPROCESSOR INTERFACING TECHNIQUES
WIZARD Engineering
8205 Ronson Road, Suite C
San Diego, CA 92111
Xybek
P.O. Box 4925
Stanford, CA 94305
446
APPENDIXC
CONVERSION TABLE
0 0000 0 0
1 0001 1 I
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 8 10
9 1001 9 11
10 1010 A 12
11 1011 B 13
12 1100 C 14
13 1101 D 15
14 1110 E 16
15 1111 F 17
447
APPENDIXD
RS232C SIGNALS
PIN FUNCTION
7 Signal ground
448
APPENDIXE
IEEE-488 SIGNALS
449
APPENDIXF
ACRONYMS
450
APPENDIX
CROM Contro!-1{()~1 FSK r rc4ucnq--Shift-Kcyinr
CKT Cathode Kay 1 Ubl'
nnc CRT Controller G (carry) Generate
cs Chip Select GI' General-l'urpos"
CTS Clear to Send C,J>JB General-Purpose Interface
cu Control Unit Bus
CY Carry
HDLC High Levd Data Link
D Data Control
D/A Digital to Analog HEX Hexadecimal
DC Direct Current Hl'IB H.-wlett-Packard
DC Don't Car.- lnlt!rface Bus
DCD Data Carrier Delt!ct
DIP Dual In-Line Package
OMA J Interrupt/Interrupt Mask
Direct Memory Access
DMAC IC Integrated Circuit = Chip
OMA Controller
INT lntt:rrupt
DMOS Double-Diffu~ed MOS
DNC I/0 Input-Output
Direct Numerical Control
DOS IOCS 1/0 Control System
Disk Operating Svstem
Dl'M
IRQ Interrupt Request
Digital Pancl Mettr
I2L Inlt!grated Injection Logic
DTL Diode-Transistor Logic
DTR Data Terminal keady
JAN Joint Army-Navy
Df)-7 Data Lines fl Through 7
JI' Jump
E Empty; Enable (Clock)
K (1024) Kilo
EAROM Electrically Altcrahk !{QM
KSR Key board-Send-l<eceive
EBCDIC Extended Binary-Coded-
Decimal Information Code
ECL Emitter Coupled Logic LCD Liquid-Crystal Display
EDP Electronic Data Processing LED Light Emitting Diode
EFL Emitter Follower Logic LIFO Last-In-First-Out
EMI Electro Ma(!'netic LOC Loop On-Line Control
Interference LP Line Printer
EOC End of Conversion LPM Lines Per Minute
EOF End of File LPS Low-Power Shottky
EOR Exclusive OR LRC Longitudinal Redundancy
EQT End of Text, Tapt: Check
£PROM Erasable PROl\1 LSB Least Significant Bit
LSI Large Scale Integration
FAMOS Floating-Galt'
Avalanche MOS MNOS Metal Nitride Oxide
FDC Floppy-Disk Con- Semiconductor
trollt:r MOS Metal Oxide Semi-
FDM Frequency-Division conductor
Multiplexing 'MPU Microprocessor Unit
FET Field-Effect Transistor MSH Most Significant Bit
FF Flip-Flop MSI Medium Scale Integration
FIFO First-In-First-Out MTBF Mean Time Between
FPLA Fit:ld PLA Failures
451
MICROPROCESSOR INTERFACING TECHNIQUES
452
INDEX
453
MICROPROCESSOR INTERFACING TECHNIQUES
454
'\
INDEX
0 s
offset 303 SlOO 251, 333
one-shot 95, 96 SAR
opto-isolator 122 sampling 266, 267
oscilloscope 410 sampling theorem 267
overhead time 84 scaling 302
scanning 108, 109
p screen overscan 149
packaging 26, 28 scheduling 74
paging 157 Schmitt trigger 96
paper tape reader 100, 129 scrolling 157
parallel buses 323 SDLC 360
parity 361 sector 166
partial decoding 42 selection 59
PIA 61, 63, 133, 137 self-diagnosis 421
PIC 85 serial 1/0 66
PIO 60, 63 servo technique 281
plastic software 437 signature analysis 416, 418, 419
PLO 183, 207 simulation 425
polling 74, 75, 80, 81 soft-fail 316
polling routine 74, 382 soft format 170
port 59, 60, 62 soft-restart 383
power fail restart 83 soft sectoring 169, 186, 188
power supplies 335, 370 software 16, 402
PPI 66, 137 software-priority 80, 81
priority 75, 83, 285 software testing 419
programs 18 spike 403
programmable 61 stack 79
programmed 1/0 74 standard microprocessor 16
static encoder 108
Q static RAM 32, 50
quad-slope 276, 279, 296, 386 status signals 37
queue · 382 stepper motor 100, 130
storage chips 32
R stored response 422
RAM 17, 32, 33, 40, 47, 385 substrate material 26, 28
RAM board 385 successive approximation 268, 269
raster scan 149 270, 275, 287, 298
readout 115 synchronous 21, 244, 258
receiver 34 synchronous communication 72,
refresh 50, 240 355, 357
refresh address 51, 156 sync tip 153
refresh controller 51, 52, 240, system controller 37, 38
243, 247
refresh memory 151, 155 T
regulation 272 Tarbell 100, 143
response times 76 teletype 67, 100, 122, 125
rollover 104 tempo 232
ROM 17, 32, 33, 38, 40, 46, 47, 97 testing 399
rotate 126, 128, 133, 136 track 166
row scanning 102 transceiver 40
RS232C 70, 122, 123, 128, 142, transmitter 34
162, 351 transparent refresh 53, 244, 251
455
MICROPROCESSOR INTERFACING TECHNIQUES
u
UART 67,68,69, 70, 73,112, 122
USART 68, 72, 140
V
vector interrupt 80,82
video 152, 154
voicing 230
VOM 405
VSYNC 148
w
walking ones 102, 103
write gate 181
X
XSDA 361
y
yield 26
z
zener 367
456
Selections from
The SVBEX Library
Technical
Assembly Language PROGRAMMING THE Z8000®
by Richard Mateosian
PROGRAMMING THE 6502 298 pp., 124 illustr., Ref. 0-032
by Rodnay Zaks How to program the Z8000 16-bit micro-
386 pp., 160 illustr., Ref. 0-135 processor. Includes a description of the
Assembly language programming for the architecture and function of the Z8000
6502, from basic concepts to advanced and its family of support chips.
data structures.
PROGRAMMING THE
6502 APPLICATIONS 8086™/8088™
by Rodnay Zaks by James W. Coffron
278 pp., 200 illustr., Ref. 0-015 300 pp., illustr., Ref. 0-120
Real-life application techniques: the input/ This book explains how to program the
output book for the 6502. 8086 and 8088 microprocessors in
assembly language. No prior program-
ADVANCED 6502 ming knowledge required.
PROGRAMMING
by Rodnay Zaks
PROGRAMMING THE 68000™
292 pp., 140 illustr., Ref. 0-089 by Steve Williams
Third in the 6502 series. Teaches more 250 pp., illustr., Ref. 0-133
advanced programming techniques, This book introduces you to micropro-
using games as a framework for learning. cessor operation, writing application pro-
grams, and the basics of 1/0
PROGRAMMING THE Z80® programming. Especially helpful for own-
ers of the Apple Macintosh or Lisa.
by Rodnay Zaks
624 pp., 200 illustr., Ref. 0-069 Hardware
A complete course in programming the
Z80 microprocessor and a thorough intro- FROM CHIPS TO SYSTEMS:
duction to assembly language. AN INTRODUCTION TO
MICROPROCESSORS
Z80® APPLICATIONS by Rodnay Zaks
by James W. Coffron 552 pp., 400 illustr., Ref. 0-063
288 pp., illustr., Ref. 0-094 A simple and comprehensive introduction
Covers techniques and applications for to microprocessors from both a hardware
using peripheral devices with a Z80 and software standpoint: what they are,
based system. how they operate, how to assemble them
into a complete system.
PROGRAMMING THE 6809
by Rodnay Zaks and William Labiak THE RS-232 SOLUTION
362 pp., 150 illustr., Ref. 0-078 by Joe Campbell
This book explains how to program the 194 pp., illustr., Ref. 0-140
6809 microprocessor in assembly lan- Finally, a book that will show you how to
guage. No prior programming knowl- correctly interface your computer to any
edge required. RS-232-C peripheral.
".· ..,
'.
~
:-·
-·
';'-
· ··
. ~' .. : . ' ...
I
I
ABOUT MICROPROCESSOR INTERFACING TECHNIQUES
"This book packs a tremendous amount of information in its 400 some
pages.. . The writing is clear and eminently readable with an informative
style that never becomes pedantic. You may either read this book as a text
devoted to the principles of microprocessor interfacing, or use it to pro-
vide detailed information to solve a particular design problem. Either way
it will serve the desired purpose admirably."
-Interface Age
" Rod nay Zaks has done an excellent job [and he] has a good knack of pro-
viding introductions and summaries with simple, direct statements . . . The
easiest to read that I have found from any source . . . An engineering tool of
value."
-Power Conversion International
INTERFACING
is no longer an art, but a set of techniques and components. This book will
teach you how to interconnect a complete system, and interface it to all
the usual peripherals. It covers hardware and software skills and tech-
niques, including the use and design of model buses such as the IEEE
488or S100.