Variables Used in the Routines
ERARNGE
This routine is used to erase either a page (64 bytes) or the whole array of FLASH. It can be used when
the internal operating frequency (f ) is between 1.0 MHz and 8.4 MHz.
op
DELNUS
This routine can generate a specified delay based on the values of register X and accumulator (A) as
parameters. DELNUS is used in ERARNGE routine.
Variables Used in the Routines
The RDVRNGE, PRGRNGE, and ERARNGE routines require certain registers and/or RAM locations to
be initialized before calling the routines in the user software. Table 1 shows variables used in the routines
and their locations.
Table 1. Variables and Their Locations
Location
RAM – RAM+7
RAM+$8
Variable Name Size (Bytes)
Description
Reserved
CTRLBYT
8
1
Reserved for future use
Control byte setting erase size
CPU speed — the nearest integer of f (in MHz) × 4;
op
RAM+$9
CPUSPD
LADDR
1
2
for example, if f = 2.4576 MHz, CPUSPD = 10
op
RAM+$A,
RAM+$B
Last address of a 16-bit range
First location of DATA array;
DATA array size must match a programming or verifying range
RAM+$C
DATA
—
Varies
2
Registers H:X
Beginning address of a 16-bit range
RAM
In general, RAM in Table 1 indicates the RAM start address. See Table 2 for RAM start locations for
specific MCUs. For example, the RAM start address for the MC68HC908LB8 (and each MCU currently
in the table) is $80.
CTRLBYT
The control byte (CTRLBYT) is located at RAM address RAM+$8 and is used for the ERARNGE routine.
In the case of the MC68HC908LB8, the CTRLBYT is located at $88. Bit 6 in this location is used to specify
either MASS (1) or PAGE (0) erase. The other bits must be 0. If one or more of these bits (except bit 6)
is initialized with 1, the erase operation is not executed.
On-Chip FLASH Programming Routines, Rev. 4
Freescale Semiconductor
3