![](http://datasheet.mmic.net.cn/Freescale-Semiconductor/MC68HC16Z1VEH16_datasheet_98737/MC68HC16Z1VEH16_34.png)
MC68HC16Z1TUT/D
4.1.3.1 Initializing the Reset Vector
Immediately after the release of RESET, an internal state machine fetches the word values at address-
es $000000 through $000006. These values, generally referred to collectively as the reset vector, are
shown in Table 7. The values in the reset vector must be initialized in order for program execution to
begin.
Sample code to initialize the reset vector follows. Make sure that the stack does not overlap the program
code (the stack grows downward in memory). If the assembler does not recognize “DW”, check the
manual to determine the format for defining a constant word. Another common format is “DC.W.” This
example is in the file “init_res.asm” in the archive “16Z1_init” on the Freeware Data System.
org
$0000
;begin at address $000000 of memory map
DW
$0000
;initial ZK, SK, and PK = 0
DW
$0200
;initial PC = $200
DW
$3000
;initial SP = $3000
DW
$0000
;initial IZ = $0000
4.1.3.2 Initializing Exception Vectors Other Than Reset
Each exception vector should point to a handler routine in case the exception is accidentally taken. In
an actual program, the vectors would point to different labels, but in the example below, all of the vectors
point to the same label (INT). This label must be included later on in the code in case an exception is
taken. This example is in the file “init_res.asm” in the archive “16Z1_init” on the Freeware Data System.
org
$0008
;put the following code in memory after the reset vector.
DW
$0000
;The address of label INT is stored at location $0008,
DW
INT
;which is the breakpoint vector
DW
INT
;Bus Error
DW
INT
;Software Interrupt
DW
INT
;Illegal Instruction
DW
INT
;Division by Zero
.
etc.
In the actual program code, the following routine must be included:
INT
{code to handle}
{the exception}
{goes here}
RTI
;return to the code that was previously being executed
4.1.4 CPU Condition Code Register
The CPU condition code register contains some very important information. The CCR is discussed on
page 3-4 of the
CPU16 Reference Manual (CPU16RM/AD). The field that the user code must initialize
is the interrupt priority level field, which consists of bits [7:5]. The interrupt priority level determines
which interrupts are recognized and which are masked. Level 7 interrupts are always recognized. To
allow other interrupts, this field must contain a value that is lower than the interrupt priority level desired.
For example, to allow level 6 interrupts, the value must be %101 or less. Out of reset, the field has a
value of %111, which disables all interrupts except for level 7 interrupts.
Table 7 Reset Vector for CPU16
Address
Reset Vector
$0000
Initial ZK, SK, and PK
$0002
Initial Program Counter Lower Word
$0004
Initial Stack Pointer Lower Word
$0006
Initial IZ Register Lower Word
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.