465
; Execute prewrite
PREWRT: MOV.W @R2+, R3
PREW: MOV.B #H'00, R6L
MOV.W #H'a, R5
PREWRS: INC R6L
MOV.B #H'00, R1H
MOV.B R1H, @R3
MOV.W #H'A579, R4
MOV.W R4, @TCSR
MOV.W R5, R4
BSET #0, @FLMCR:8
; Set P bit
LOOPR1: SUBS #1, R4
MOV.W R4, R4
BNE LOOPR1
BCLR #0, @FLMCR:8
; Clear P bit
MOV.W #H'A500, R4
MOV.W R4, @TCSR
; Prewrite starting address
; Prewrite-verify fail counter
; Prewrite-verify loop counter
; Prewrite-verify fail counter + 1
→
R6L
;
; Write H'00
;
; Start watchdog timer
; Set prewrite loop counter
;
;
; Wait loop
;
; Stop watchdog timer
MOV.B #H'c, R4H
LOOPR2: DEC R4H
BNE LOOPR2
MOV.B @R3, R1H
BEQ PWVFOK
CMP.B #H'06, R6L
BEQ ABEND1
ADD.W R5, R5
BRA PREWRS
; Set prewrite-verify loop counter
;
; Wait loop
; Read data = H'00
; If read data = H'00 branch to PWVFOK
; Prewrite-verify executed 6 times
; If prewrite-verify executed 6 times, branch to ABEND1
; Programming time
×
2.
; Prewrite again
ABEND1:
Programming error
PWVFOK: ADDS #1, R3
MOV.W @R2, R4
CMP.W R4, R3
BNE PREW
PWADD2: INC R1L
BRA PRETST
; Address + 1
→
R3
; Top address of next block
; Last address
; If not last address, prewrite next address
; Used to test R1L+1 bit in R0
; Branch to PRETST
; Execute erase
ERASES: MOV.W #H'0000, R6
MOV.W #H'd, R5
ERASE: ADDS #1, R6
MOV.W #H'e, R4
MOV.W R4, @TCSR
MOV.W R5, R4
BSET #1, @FLMCR:8
; Set E bit
LOOPE: NOP
NOP
NOP
NOP
SUBS #1, R4
MOV.W R4, R4
BNE LOOPE
BCLR #1, @FLMCR:8
; Clear E bit
MOV.W #H'A500, R4
MOV.W R4, @TCSR
; Erase-verify fail counter
; Set erase loop count
; Erase-verify fail counter + 1
→
R6
;
; Start watchdog timer
; Set erase loop counter
;
;
; Wait loop
;
; Stop watchdog timer