LOOPDW: DEC.W #1, R4 ;
BPL LOOPDW ;
Wait
MOV.B @ER3+, R4H ;
Read
CMP.B #FF, R4H ;
Read data = H’FF?
BNE RERASE ;
If read data
≠
H’FF, branch to RERASE
CMP.L ER2, ER3 ;
Last address in block?
BGT EVR2 ;
If not last address in block, erase-verify
next address
BRA OKEND, ;
Branch to OKEND
RERASE: MOV.W #4000, R5 ;
MOV.B R5H, @FLMCR:8 ;
Clear EV bit
DEC.L #1, ER3 ;
Erase-verify address – 1
→
R3
CMP.W #0004, R0 ;
BGE KEEP ;
Erase executed 4 times?
SHLL.W E4 ;
Double erase loop counter value
KEEP: BRA ERASE ;
Erase again
OKEND: MOV.W #4000, R5 ;
MOV.B R5H, @FLMCR:8 ;
Clear EV bit
MOV.W #0000, R5 ;
MOV.W R5, @EBR1:16 ;
Clear EBR1 and EBR2
MOV.B R5L, @FLMCR:8 ;
Clear V
PP
E bit
.............................
One block erased
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
599
www.DataSheet4U.com