Datasheet

CHAPTER 16 FLASH MEMORY
User’s Manual U18172EJ3V0UD
264
An example of a program when the command execution time (from erasure to black check) should be minimized in
self programming mode is shown below.
;---------------------------------------------------------------------
;START
;---------------------------------------------------------------------
MOV MK0,#11111111B ; Masks all interrupts
MOV FLCMD,#00H ; Clears FLCMD register
DI
ModeOnLoop: ; Configure settings so that the CPU clock 1 MHz
MOV PFS,#00H ; Clears flash status register
MOV PFCMD,#0A5H ; PFCMD register control
MOV FLPMC,#01H ; FLPMC register control (sets value)
MOV FLPMC,#0FEH ; FLPMC register control (inverts set value)
MOV FLPMC,#01H ; Sets self programming mode with FLPMC register control (sets
; value)
NOP
HALT
BT PFS.0,$ModeOnLoop ; Checks completion of write to specific registers
; Repeats the same processing when an error occurs.
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 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.
FlashBlockBlankCheck:
MOV FLCMD,#04H ; Sets flash control command (block blank check)
MOV FLAPH,#07H ; Sets number of block 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 of
; FLAPH)