XC886/888CLM
Flash Memory
User’s Manual
4-16
V1.3, 2010-02
Flash Memory, V 1.0
4.8.1
Flash Programming
Each call of the Flash program subroutine allows the programming of 64 and 32 bytes of
data into the selected wordline (WL) of the P-Flash and D-Flash bank respectively.
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 programming of
the selected WL is completed.
Before calling this subroutine, the user must ensure that the 64-byte or 32-byte WL
contents are stored incrementally in the IRAM, starting from the address specified in R0
of current general register bank. In addition, the input DPTR must contain a valid Flash
WL address (WL addresses of a protected Flash bank are considered invalid).
Otherwise, PSW.CY bit will be set and no programming will occur. If valid inputs are
available before calling the subroutine, the microcontroller will continue with the
initialization sequence (includes transferring the 64-byte or 32-byte IRAM data to the
selected Flash bank write buffers), exit the subroutine and then return to the user
program code (see
). User program code will continue execution, from where
it last stopped, until the Flash NMI event is generated; the NMISR.FNMIFLASH bit is set,
and if enabled via NMIFLASH, an NMI to the CPU is triggered to enter the Flash NMI
service routine (see
). At this point, all Flash banks are in ready-to-read mode.
Table 4-1
Flash Program Subroutine
Subroutine
DFF6
H
: FLASH_PROG
1)
1)
The time taken by the subroutine from the calling of the subroutine to the setting of the NMI flag can be split
into two components. One is the time from the calling of the subroutine to the return to the calling function,
which is <100
µ
s for D-Flash and <150
µ
s for P-Flash, the other is the time needed by the Flash State
Machine, which is given by the formula 248256/
f
SYS
.
Input
DPTR (DPH, DPL
2)
): Flash WL address
R0
IRAM start address for 64/32-byte Flash data
64/32-byte Flash data for P/D Flash respectively
Flash NMI (NMICON.NMIFLASH) is enabled (1) or disabled (0)
Output
PSW.CY:
0 = Flash programming is in progress
1 = Flash programming is not started
DPTR is incremented by 20
H
or 40
H
3)
Stack size required
7 bytes
Resource
used/destroyed
ACC, B, SCU_PAGE, PSW
R0 – R7 of Current Register Bank (8 bytes)
*