Chapter 1: Introduction To HCS12/MC9S12 The HCS12 Microcontroller Han-Way Huang Minnesota State University, Mankato September 2009
Chapter 1: Introduction To HCS12/MC9S12 The HCS12 Microcontroller Han-Way Huang Minnesota State University, Mankato September 2009
Chapter 1: Introduction To HCS12/MC9S12 The HCS12 Microcontroller Han-Way Huang Minnesota State University, Mankato September 2009
Modulus Math
Computers perform modulus math because it uses a limited number of bits
(e.g., 8, 16, or 32 bits) to represent numbers.
Copyright 2010 Delmar Cengage Learning
What is a computer?
Software
Hardware
Computer Hardware Organization
The Processor
Control Unit
The control unit decodes machine codes and performs the operations specified
by the machine code.
A machine instruction has several fields. A mandated field is the opcode field.
Instruction execution is timed by a clock signal.
The frequency of the clock signal used in an 8-bit or 16-bit microcontroller is
from
a few mega hertz to several hundred mega Hertz
The control unit uses a program counter to keep track of the address of the
instruction to be executed next.
The fetched instruction is placed in the instruction register when is decoded,
and executed.
Program instructions are normally stored in sequential locations in memory.
The processor may not execute instructions in sequential due to the need to
execute instructions based on the condition or the need to repeat a certain group
of instructions.
The processor uses conditional and unconditional branch (or jump)
instructions to change the program flow.
Registers
Microprocessor
Microcontroller
Microcontrollers have been used in almost every product that requires a certain
amount of intelligence.
Microcontrollers have been used as controllers for displays, printers, keyboards,
modems, charge card phones, palm-top computers, home appliances such as
washing machines and microwave ovens, automobile control, and so on.
Embedded Systems
Memory Technologies
Magnetic Memory
Magnetic drums, magnetic tapes, and magnetic disks are the three major magnetic
memory devices that have been invented.
Only magnetic disks are still being widely used today
Hard disks are rarely used in an embedded system
Optical Memory
Compact disk (CD) and digital video disc (DVD) are two major optical memory devices.
CD was introduced in 1982.
CD has two versions: CD-R and CD-RW.
The capacity of a 12-inch CD is 700 MB.
A 12-inch DVD has the capacity of 4.7 GB
DVD has two versions: DVD-R and DVD-RW versions.
Semiconductor Memory
Semiconductor memory can be classified on the basis of volatility and read-writability.
On the basis of volatility, semiconductor memory is divided into volatile and
non-volatile memory.
On the basis of read-writability, semiconductor memory is divided into random-access
memory (RAM) and read-only memory (ROM).
Copyright 2010 Delmar Cengage Learning
Random-access memory
There are four types of RAM:
Dynamic random-access memory (DRAM):
The one-bit cell of DRAM consists of one transistor and one capacitor.
The information is stored in the capacitor whereas the transistor controls the access of
the information stored in the capacitor.
Periodic refresh is required to maintain the contents of a DRAM chip
Static random-access memory (SRAM):
The one-bit of SRAM consists of 4 to 6 transistors.
No periodic refresh operation is required to maintain the information stored in SRAM.
Magneto RAM (MRAM):
The one-bit cell of MRAM consists of two magnetic plates each of which can hold a
magnetic field, separated by a thin insulating layer. One of the plates is a permanent
magnet set to a particular polarity.
A MRAM chip combines a magnetic device with standard silicon-based microelectronics
to achieve the attributes of non-volatility, high-speed operation, and unlimited read and
write endurance
Read-Only Memory
ROM is nonvolatile.
There are several types of ROM technologies.
Computer software
Machine instruction
Assembly language
High-level language
Source code
Object code
line
addr.
1:
machine code
source code
= 00002000
org $2000
2:
2000
B6 1000
ldaa $1000
3:
2003
BB 1001
adda $1001
4:
2006
BB 1002
adda $1002
5:
2009
7A 1100
staa $1100
6:
end
Read Operation
The processor places the address of the memory location that it intends to read on
the address bus and asserts the RD signal.
The RD signal enables the memory chip to send out the contents of the selected location
on the data bus and the processor gets the data.
Write Operation
The processor places the address of the location that it intends to write on the address
bus.
The processor also places the data that it intends to write on the data bus and asserts
the WE signal.
In responds to the WE signal, the memory chip stores the data on the data bus in the
selected memory location.
Program Execution
To understand how processor executes the program, we need to answer the following
questions:
Where does the processor start to execute program after power on?
From a fixed location such as address 0: PIC18, Atmel avr, and 8051
Fetch the starting address from a fixed location: HCS12
How does the processor update the program counter (PC)?
Increment the program counter by the length of the instruction just executed.
Increment or decrement by the amount specified in the current instructionconditional
and unconditional branch instructions.
Set to the new address specified by the current instructionjump (or goto) instruction or
subroutine call instruction.
A common building block of PC is the D flip-flop with set and reset capability (Figure 1.3).
The program counter circuit that can be forced to 0, incremented by 1, incremented by
a field in the instruction, and loaded with a jump target is shown in Figure 1.4.
Step 2
The opcode (0xE0) returned in Step 1 requires the processor to perform a read operation
Using the address stored in ptr register. Processor X places the contents of ptr register
on the data memory address bus and request a read operation.
Step 3
Data memory returns the byte in data memory pointed to by ptr register. This byte is
placed in A.