Page 27 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 27
4 Chapter 1 Basic Computer Structure and the 6812
We can enlarge our description of how the memory works. Assume that we want to
get the contents of a particular word or byte from memory, that is, read a word from
memory. The MPU first puts a 1 for read on the read/write line and then puts the address
of the desired word or byte on the address bus throughout the duration of a clock cycle.
The memory is designed so that, at the end of the clock cycle, the desired word is put on
the data bus. The MPU then places a copy of the contents of the word or byte on the data
bus into some register inside the MPU as required by the instruction that it is executing.
This is done without changing the contents in memory of the word or byte addressed.
To write a word into memory, the address of the word is put on the address bus, the
word is put on the data bus, and the read/write line has 0 (to indicate a write) for a full
clock cycle. The memory is designed to store the word at that address at the end of the
clock cycle. After the word is stored at the given address, the MPU may still retain in
one of its registers a copy of the word that has just been written.
The MPU can read or write an 8-bit or a 16-bit word in memory in one clock cycle.
Such a memory is usually called random access memory or RAM because each byte is
equally accessible or can be selected at random without changing the time of the access.
With microcomputer applications, it is not unusual to have part of the memory bytes in
ROM (read only memory). A ROM is capable of a read operation but not a write
operation; its words are written when it is made at the factory and are retained even when
the power is turned off. If the data in a RAM are lost when power is turned off, the RAM
is termed volatile; otherwise, it is termed nonvolatile. RAM memories are essentially
volatile. The term RAM is also used almost universally to imply memories that you can
read and write in, even though ROM memories can be randomly accessed with a read
operation. The part of memory that is in ROM is typically used to store & program for a
microcomputer that only executes one program. For example, the microcontroller used in
an automobile would be running the same program every time it is used, so that the part
of the memory that is used for storing the program is in ROM.
1.2 The Instruction
We now examine the notion of an instruction, which is an indivisible operation
performed by the MPU. It can be described statically as a collection of bits stored in
memory or as a line of a program or, dynamically, as a sequence of actions by the
controller. In this discussion we begin with a simplified dynamic view of the instruction
and then develop a static view. Examples are offered to combine these views to explain
the static aspects of the operation code, addressing mode, machine code, and mnemonics.
We conclude with an expanded view of the dynamic aspects of the instruction cycle.
The controller will send commands to memory to read or write and will send
commands to all other parts of the computer to effectively carry out the intentions of the
programmer. The specification of what the control unit is to do is contained in a
program, a sequence of instructions stored, for the most part, in consecutive bytes of
memory. To execute the program, the MPU controller repeatedly executes the
instruction cycle (or fetch/execute cycle):
1. Fetch (read) the next instruction from memory. 2. Execute the instruction.