CHAPTER 16 FLASH MEMORY
User’s Manual U18172EJ2V0UD
266
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 via 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.
RET
;---------------------------------------------------------------------
; Processing to shift to normal mode
;---------------------------------------------------------------------
ModeOffLoop:
MOV
FLCMD,#00H
; Clears FLCMD register
MOV
PFS,#00H
; Clears flash status register
MOV
PFCMD,#0A5H
; PFCMD register control
MOV
FLPMC,#00H
; FLPMC register control (sets value)
MOV
FLPMC,#0FFH
; FLPMC register control (inverts set value)
MOV
FLPMC,#00H
; Sets normal mode via FLPMC register control (sets value)
BT PFS.0,$ModeOffLoop
; Checks completion of write to specific registers
; Repeats the same processing when an error occurs.
; After the specific sequence is correctly executed, restore
; the CPU clock to its setting before the self programming
MOV
MK0,#INT_MK0
; Restores interrupt mask flag
EI
RET
;---------------------------------------------------------------------
;Data to be written
;---------------------------------------------------------------------
DataAdrTop:
DB XXH
DB XXH
DB XXH