XC886/888CLM
Flash Memory
User’s Manual
4-17
V1.3, 2010-02
Flash Memory, V 1.0
4.8.2
Flash Erasing
Each call of the Flash erase subroutine only allows either the P-Flash bank(s) or the
D-Flash bank to be erased. Hence, while it is possible to erase the P-Flash banks in
parallel, it is not possible to erase both the P-Flash and D-Flash banks simultaneously.
For each Flash bank, the user can select one sector or a combination of several sectors
for erase. Before calling this subroutine, the Flash NMI can be enabled via bit
NMIFLASH in register NMICON so that the Flash NMI service routine is entered once
the erase operation on the Flash bank(s) is completed.
Before calling this subroutine, the user must ensure that R0, R1 and R3 to R7 of the
Current Register Bank are set accordingly (see
). Also, protected Flash banks
should not be targeted for erase. If valid inputs are available before calling the
subroutine, the microcontroller will continue with the initialization sequence, exit the
subroutine and then return to the user program code. User program code will continue
execution, from where it last stopped, until the Flash NMI event is generated; bit
FNMIFLASH in register NMISR is set, and if enabled via NMIFLASH, an NMI to the CPU
is triggered to enter the Flash NMI service routine (see
Flash banks are in ready-to-read mode.
2)
For P-Flash programming,the last 6 LSB of the DPL is 0 for aligned WL address, for e.g. 40
H
, 80
H,
C0
H
and
100
H
. As for the D-Flash programming, the last 5 LSB of the DPL is 0 for an aligned WL address, for e.g. 00
H
,
20
H
, 40
H
, 60
H
, 80
H
, A0
H
, C0
H
and E0
H
.
3)
DPTR is only incremented by 40
H
and 20
H
when PSW.CY is 0 for the P-Flash and D-flash programming.
Table 4-2
Flash Erase Subroutine
Subroutine
DFF9
H
: FLASH_ERASE
1)
Input
2)
R0
Select sector(s) to be erased for D-Flash bank 0.
LSB represents sector 0, MSB represents sector 7.
R1
Select sector(s) to be erased for D-Flash bank 0.
LSB represents sector 8, bit 1 represents sector 9.
R3
Select sector(s) to be erased for D-Flash bank 1.
LSB represents sector 0, MSB represents sector 7.
R4
Select sector(s) to be erased for D-Flash bank 1.
LSB represents sector 8, bit 1 represents sector 9.
R5
Select sector(s) to be erased for P-Flash Bank Pair 0.
LSB represents sector 0, bit 2 represents sector 2.
*