LOOPR1: DEC.W #1, E1 ;
Program
BPL LOOPR1 ;
MOV.B R5L, @FLMCR:8 ;
Clear P bit
MOV.W #A500, R5 ;
MOV.W R5, @TCSR:16 ;
Stop watchdog timer
MOV.W #c, R5 ;
Prewrite-verify loop counter
LOOPR2: DEC.W #1, R5 ;
BPL LOOPR2 ;
MOV.B @ER3, R5H ;
Read data = #'00?
BEQ PWVFOK ;
If read data = #'00, branch to PWVFOK
PWVFNG: CMP.B #06, R1H ;
Prewrite-verify executed 6 times?
BEQ ABEND1 ;
If prewrite-verify executed 6 times, branch to ABEND1
INC.B R1H ;
Prewrite-verify fail count + 1
→
R1H
SHLL.W E0 ;
Double prewrite loop counter value
BRA PREWRS ;
Prewrite again
PWVFOK: INC.L #1, ER3 ;
A 1
→
ER3
CMP.L ER4, ER3 ;
Last address?
BEQ PWADD2 ;
BRA PREW ;
PWADD2: INC.B R1L ;
Used to test (R1L + 1)–th bit in R0
BRA PRETST ;
Branch to PRETST
;
Execute erase
ERASES: MOV.W R6, @EBR1:16 ;
Set EBR1/EBR2
SUB.W E6, E6 ;
E6: erase-verify fail count
MOV.W #d, E0 ;
Set initial erase loop counter value
ERASE: MOV.W #f , R5 ;
MOV.W R5, @TCSR:16 ;
Start watchdog timer
MOV.W E0, E1 ;
Set erase-loop counter
MOV.W #4240, R5 ;
MOV.B R5H, @FLMCR:8 ;
Set E bit
LOOPE: PUSH.L ER5
POP.L ER5
PUSH.L ER5
POP.L ER5
PUSH.L ER5
POP.L ER5
DEC.W #1, E1 ;
Erase
BPL LOOPE
MOV.B R5L, @FLMCR:8 ;
Clear E bit
MOV.W #A500, R5 ;
MOV.W R5, @TCSR:16 ;
Stop watchdog timer
603
www.DataSheet4U.com