18.7.6 Erasing Flowchart and Sample Program
Flowchart for Erasing One Block
Figure 18-16 Erasing Flowchart
Start
Write 0 data in all addresses
to be erased (prewrite)
*
1
n = 1
Set erase block register
(set bit of block to be erased to 1)
Enable watchdog timer
Wait initial value setting x = 6.25 ms
*
2
Select erase mode
(E bit = 1 in FLMCR)
Clear E bit
Disable watchdog timer
Set top address in block
as verify address
Select erase-verify mode
(EV bit = 1)
Wait (t
VS1
)
µ
s
Dummy write to verify address
*
3
(flash memory latches address)
Verify (read memory)
*4
Last address?
A 1
→
address
Yes
OK
No
No good
No
No
Yes
Yes
Clear EV bit
Clear erase block register
(clear bit of erased block to 0)
End of block erase
Clear EV bit
Erase error
n
≥
N?
n
≥
5?
Erase-verify ends
Erasing ends
n + 1
Double the erase time
(x
×
2
→
x)
→
n
Wait (z)
µ
s
V E
PP
Set bit
( bit = 1 in FLMCR)
V E
PP
Clear bit
V E
PP
Clear bit
Wait (x) ms
V E
PP
Wait (t
VS2
)
µ
s
Clear erase block register
(clear bit of block to be
erased to 0)
Notes: 1. Program all addresses to be
erased by following the prewrite
flowchart.
2. Set the watchdog timer overflow
interval to the value indicated in
table 18-15.
3. For the erase-verify dummy
write, write H'FF using a byte
transfer instruction.
4. Read to verify data from the
memory using a byte transfer
instruction.
5. t
VS1
: 4 µs
z:
5 to 10 µs
t
VS2
: 2 µs
N:
602
6. The erase time x is successively
incremented by the initial set
value
×
2
n–1
(n = 1, 2, 3, 4). An
initial value of 6.25 ms or less
should be set, and the time for
one erasure should be 50 ms or
less.
595
www.DataSheet4U.com