
- •Contents
- •Preface
- •List of Figures
- •List of Tables
- •Acknowledgments
- •1.1.2 The Instruction
- •1 Problems
- •2 Programming Microcomputers
- •3 Bus Hardware and Signals
- •3.3 Conclusions
- •3 Problems
- •5 Interrupts and Alternatives
- •5.4.1 Direct Memory Access
- •7.1.3 Other Transducers
- •7.2 Basic Analog Processing Components
- •7.2.1 Transistors and Silicon Controlled Rectifiers
- •8 Counters and Timers
- •9. Communications Systems
- •9.3.3 The ACIA
- •9.4.4 The Small Computer System Interface (SCSI)
- •9.5 Conclusions
- •10.1.2 A 6812 SPI Display
List of Tables
Table Title |
Page |
Table 1.1. Addressing Modes for the 6812 |
II |
Table 1.2. 6812 Move Instructions |
17 |
Table 1.3. 6812 Arithmetic Instructions |
19 |
Table 1.4. 6812 Logic Instructions |
21 |
Table 1.5. 6812 Edit Instructions |
22 |
Table 1.6. 6812 Control Instructions |
23 |
Table 1.7. Assembly-LanguageDirectives for the 6812 |
29 |
Table 2.1. Conventional C Operators Used in Expressions |
47 |
Table 2.2. Special C Operators |
49 |
Table 2.3. Conditional Expression Operators |
49 |
Table 2.4, ASCII Codes |
60 |
Table 3.1. Address Map for a Microcomputer |
108 |
Table 3.2. Outputs of a Gate |
116 |
Table 3.3. Another Address Map for a Microcomputer |
117 |
Table 4.1. Traffic Light Sequence |
149 |
Table 4.2. LCD Commands |
165 |
Table 5.1. Interrupt Vectors in the 6812 |
228 |
Table 7.1. Characteristics of the CA3140 |
321 |
Table 8.1. PWM Channel Ports |
369 |
Table 8.2. Touch-tone Codes |
370 |
Table 9.1. RS-232 Pin Connections for D25P and D25S Connectors |
404 |
Table 9.2. ACIA Control and Status Bits |
415 |
xxi
Acknowledgments
The author would like to express his deepest gratitude to everyone who contributed to the evelopment of this book. The students of EE 345L at the University of Texas at Austin uring Fall 1998 significantly helped correct this book; special thanks are due to Levent Og, Ed Limbaugh, and Greg McCasKill, who located most of the errors. This text was repared and run off using a Macintosh and LaserWriter, running WriteNow. I am pleased o write this description of the Motorola 6812, which is an incredibly powerful omponent and a vehicle for teaching a considerable range of concepts.
G. J. L.
xxu



1.1 An Introductionto the Microcomputer
Input/output
Figure 1.1. Analogy to the von Neumann Computer
to an organization as a partial name without the suffix, for example, the MC68HC812A4 (without PV8), which we abbreviate as 'A4, or the MC68HC912B32, abbreviated as 'B32 and refer to the architecture as a number 6812. This should clear up any ambiguity, while also being a natural, easy-to-read shorthand.
The architecture of von Neumann computers is disarmingly simple, and the following analogy shows just how simple. (For an illustration of the following terms, see Figure 1.1.) Imagine a person in front of a mailbox, with an adding machine and window to the outside world. The mailbox, with numbered boxes or slots, is analogous to the primary memory; the adding machine, to the data operator (arithmetic-logic unit); the person, to the controller; and the window, to input/output (I/O). The person's hands access the memory. Each slot in the mailbox has a paper that has a string of, say, eight Is and Os (bits) on it. A string of 8 bits is a byte. A string of bits - whether or not it is a byte - in a slot of the memory box is called a word.
The primary memory may be in part a random access memory (RAM) (so-called because the person is free to access words in any order at random, without having to wait any longer for a word because it is in a different location). RAM may be static ram (SRAM) if bits are stored in flip-flops, or dynamic ram (DRAM) if bits are stored as charges in capacitors. Memory that is normally written at the factory, never to be rewritten by the user, is called read-only memory (ROM). A programmable read-only memory (PROM) can be written once by a user, by blowing fuses to store bits in it. An erasable programmable read-only memory (EPROM) can be erased by ultraviolet light and then written electrically by a user. An electrically erasable programmablereadonly memory (EEPROM) can be erased and then written by a user, but erasing and writing words in EEPROM takes several milliseconds. A variation of this memory, called flash, is less expensive but cannot be erased one word at a time.
With the left hand the person takes out a word from slot or box n, reads it as an instruction, and replaces it. Bringing a word from the mailbox (primary memory) to the person (controller) is called fetching. The hand that fetches a word from box n is analogous to the program counter. It is ready to take the word from the next box, box n + 1, when the next instruction is to be fetched.


1.1 An Introduction to the Microcomputer |
5 |
Now that we have some ideas about instructions, we resume the analogy to illustrate some things an instruction might do. For example, an instruction may direct the controller to take a word from a box m in the mailbox with the right hand, copy it into the adding machine (thus destroying the old word) and put the word back in the box. This is an example of an instruction called the load instruction. In the 6812 an instruction to load accumulator A with the word at location 256 in decimal, or $100 in hexadecimal, is fetched as three words
$B6 $01 $00
where the second word is the most significant byte, and the third is the least significant byte, of the address and is represented by mnemonicsas
LDAA $100
in assembly language. The main operation - bringing a word from the mailbox (primary memory) to the adding machine (data operator) - is called recalling data. The right hand is used to get the word; it is analogous to the effective address.
As with instructions, assembly language uses a shorthand to represent locations in memory. A symbolic address, which is actually some address in memory, is a name that means something to the programmer. For example, location $100 might be called ALPHA. Then the assembly-language instruction above can be written as follows
LDAA ALPHA
We will be using the symbolic address ALPHA in most of our examples in this chapter, and it will represent location $100. Other symbolic addresses and other locations can be substituted, of course. It is important to remember that a symbolic address is just a representation of a number, which usually happens to be the numerical address of the word in primary memory to which the symbolic address refers. As a number, it can be added to other numbers, doubled, and so on. In particular, the instruction
LDAA ALPHA+1
will load the word at location $101 (ALHPA + 1 is $100+1) into the accumulator. Generally, after such an instruction has been executed, the left hand (program
counter) is in position to fetch the next instruction in box n + 1. For example, the next instruction may give the controller directions to copy the number in the adding machine into a box in the mailbox, causing the word in that box to be destroyed. This is an example of a store instruction. In the 6812, the instruction to store accumulator A into location $100 can be written like this
STAA ALPHA
The main operation in this store instruction - putting a word from the adding machine (data operator) into a box in the mailbox (primary memory) - is called memorizing data. The right hand (effective address) is used to put the word into the box.