Sample Program for Erasing One Block:
This program uses the following registers.
R0:
ER1: Stores address used in prewrite
ER2: Stores address used in prewrite and erase-verify
ER3: Stores address used in erase-verify
ER4: Timing loop counter
R5:
Sets appropriate registers
R6:
Sets appropriate registers
Prewrite-verify and erase-verify fail counter
The values of #a, #c, #d, #e, #f, #g, and #h, in the program depend on the clock frequency. They
can be calculated as indicated in tables 18-14 and 18-15.
FLMCR: .EQU FFFF40
EBR1: .EQU FFFF42
EBR2: .EQU FFFF43
TCSR: .EQU FFFFA8
;
#BLKSTR is top address of block to be erased
;
#BLKEND is last address of block to be erased
MOV.L #BLKSTR:32, ER1 ;
ER1: top address of block to be erased
MOV.L #BLKEND:32, ER2 ;
ER2: last address of block to be erased
;
Execute prewrite
PREWRT: MOV.W #g, R4 ;
Set wait counter
MOV.W #4140, R6 ;
MOV.B R6L, @FLMCR:8 ;
Set V
PP
E bit
LOOPR0: DEC.W #1, R4 ;
BPL LOOPR0 ;
;
SET EBR1 or EBR2 bit of block to be erased
MOV.B #**, R5H ;
MOV.B R5H, @EBR* ;
Set EBR*
PREWRN: SUB.B R0H, R0H ;
R0: prewrite-verify fail count
MOV.W #a, E4 ;
Set initial prewrite loop counter value
PREWRS: MOV.B #00, R5H ;
Write #00 data
MOV.B R5H, @ER1 ;
MOV.W #A579, R5 ;
Start watchdog timer
MOV.W R5, @TCSR:16 ;
MOV.W E4, R4 ;
Set prewrite loop counter
MOV.W #4140, R6 ;
MOV.B R6H, @FLMCR:8 ;
Set P bit
LOOPR1: DEC.W #1, R4 ;
Prewrite
BPL LOOPR1 ;
MOV.B R6L, @FLMCR:8 ;
Clear P bit
MOV.W #A500, R5 ;
Stop watchdog timer
MOV.W R5, @TCSR:16 ;
MOV.W #c , R5 ;
Set prewrite-verify loop counter
597