CHAPTER 18 FLASH MEMORY
User’s Manual U16898EJ3V0UD
311
An example of a program when the interrupt-disabled time (from erasure to blank check) should be minimized in
self programming mode is shown below.
;---------------------------------------------------------------------
;START
;---------------------------------------------------------------------
FlashBlockErase:
; Sets erase command
MOV
FLCMD,#03H
; Sets flash control command (block erase)
MOV
FLAPH,#07H
; Sets number of block to be erased (block 7 is specified here)
MOV
FLAPL,#00H
; Fixes FLAPL to “00H”
MOV
FLAPHC,#07H
; Sets erase block compare number (same value as that of FLAPH)
MOV
FLAPLC,#00H
; Fixes FLAPLC to “00H”
CALL
!ModeOn
; Shift to self programming mode
; Execution of erase command
MOV
PFS,#00H
; Clears flash status register
MOV
WDTE,#0ACH
; Clears & restarts WDT
HALT
; Self programming is started
MOV
A,PFS
CMP
A,#00H
BNZ
$StatusError
; Checks erase error
; Performs abnormal termination processing when an error
;
occurs.
CALL
!ModeOff
; Shift to normal mode
; Sets blank check command
MOV
FLCMD,#04H
; Sets flash control command (block blank check)
MOV
FLAPH,#07H
; Sets block number for blank check (block 7 is specified here)
MOV
FLAPL,#00H
; Fixes FLAPL to “00H”
MOV
FLAPHC,#07H
; Sets blank check block compare number (same value as that of
;
FLAPH)
MOV
FLAPLC,#0FFH
; Fixes FLAPLC to “FFH”
CALL
!ModeOn
; Shift to self programming mode
; Execution of blank check command
MOV
PFS,#00H
; Clears flash status register
MOV
WDTE,#0ACH
; Clears & restarts WDT
HALT
; Self programming is started
MOV
A,PFS
CMP
A,#00H
BNZ
$StatusError
; Checks blank check error
; Performs abnormal termination processing when an error occurs