HANTEI: MOV.W #4000, R5 ;
MOV.B R5H, @FLMCR:8 ;
Clear EV bit
MOV.W R0, @EBR1:16 ;
Clear bit of erased block to 0
BEQ EOWARI ;
If EBR1/EBR2 is all 0, erasing ended normally
CMP.W #025A, E6 ;
E6 = 025A? (erase-verify fail count = 602?)
BEQ ABEND2 ;
If E6 = 025A, branch to ABEND2
INC.W #1, E6 ;
Erase-verify fail count + 1
→
E6
CMP.W #0004, E6 ;
BGE KEEP ;
Erase executed 4-times?
SHLL.W E0 ;
Double erase loop counter value
KEEP: BRA ERASE ;
Erase again
;———————<
Block address table used in erase-verify
>———————————————————————
.ALIGN2
ERVADR: .DATA.L 00000000 ; #0000 LB0
.DATA.L 00004000 ; #4000 LB1
.DATA.L 00008000 ; #8000 LB2
.DATA.L 0000C000 ; #C000 LB3
.DATA.L 00010000 ; #10000 LB4
.DATA.L 00014000 ; #14000 LB5
.DATA.L 00018000 ; #18000 LB6
.DATA.L 0001C000 ; #1C000 LB7
.DATA.L 0001F000 ; #1F000 SB0
.DATA.L 0001F200 ; #1F200 SB1
.DATA.L 0001F400 ; #1F400 SB2
.DATA.L 0001F600 ; #1F600 SB3
.DATA.L 0001F800 ; #1F800 SB4
.DATA.L 0001FA00 ; #1FA00 SB5
.DATA.L 0001FC00 ; #1FC00 SB6
.DATA.L 0001FE00 ; #1FE00 SB7
.DATA.L 00020000 ; #20000
FLASH AREA END ADDRESS
EOWARI: MOV.B #00, R5L ;
MOV.B R5L, @FLMCR:8 ;
Clear V
PP
E bit
Erase end
ABEND1: MOV.W #0000, R5 ;
MOV.W R5, @EBR1:16 ;
Clear EBR1 and EBR2
MOV.B R5L, @FLMCR:8 ;
Clear V
PP
E bit
Programming error
ABEND2: MOV.W #0000, R5 ;
MOV.W R5, @EBR1:16 ;
Clear EBR1 and EBR2
MOV.B R5L, @FLMCR:8 ;
Clear V
PP
E bit
Erase error
605
www.DataSheet4U.com