CHAPTER 18 FLASH MEMORY
User’s Manual U16898EJ3V0UD
292
An example of a program that performs a block erase in self programming mode is shown below.
;----------------------------
;START
;----------------------------
FlashBlockErase:
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”
MOV
PFS,#00H
; Clears flash status register
MOV
WDTE,#0ACH
; Clears & restarts WDT
HALT
; Self programming is started
MOV
A,PFS
MOV
CmdStatus,A
; Execution result is stored in variable
; (CmdStatus = 0: normal termination, other than 0: abnormal
;
termination)
;----------------------------
;END
;----------------------------