AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 30

no-image

AN2153

Manufacturer Part Number
AN2153
Description
A Serial Bootloader for Reprogramming the MC9S12DP256 FLASH Memory
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
Erase Command
Code
30
constraint before performing a read operation on the FLASH will result
in the setting of the ACCERR bit and any pending programming
commands will be terminated. The verification process begins by
reinitializing the DataBytes local variable and the X and Y index
register pointers. If any of the programmed words do not match the
S-record data, a “not equal” condition (Z bit in the CCR equal to 0) is
returned.
The code comprising the FLASH erase command is not nearly as simple
as the programming code; it consists of five subroutines. The reason for
the additional complexity surrounds the method that must be used to
erase a FLASH block containing protected areas. When a 64-K block
has a portion of its contents protected from being erased or
programmed, the FLASH’s mass erase command cannot be used.
Instead, the unprotected areas must be erased one 512-byte sector at a
time. Because the time required to erase a sector is 20 ms versus
100 ms for the mass erase operation, erasure of a 64-K block with
protected areas requires much longer. In this case where the bootloader
resides in a 4-K protected area of block zero, 120 sector erase
operations must be performed. Not counting the time required to verify
each sector erasure, the sector erase operations require 2.4 seconds
(20 ms * 120 sectors).
The FLASH erase command begins with the subroutine EraseFlash,
called through the command table. This subroutine coordinates the
activities of the other four subroutines. It begins by performing a mass
erase and verify on three of the 64-K FLASH blocks. After all three of the
64-K FLASH blocks have been successfully erased, the EraseBlk0
subroutine is called to perform a sector by sector erase of the
unprotected portion of FLASH block zero.
The EraseBlk0 subroutine begins by allocating and initializing the local
variable PPAGECnt. The initialized value of three is the number of 16-K
PPAGE windows that will be completely erased a sector at a time. The
PPAGE register is initialized with a value passed in the B accumulator
from the EraseFlash subroutine. This value, $3C, places the lower
16 K of FLASH block zero into the PPAGE window. The block select bits
are initialized to zero. After loading the X index register with the address
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
AN2153

Related parts for AN2153