18.7.3 Programming Flowchart and Sample Program
Flowchart for Programming One Byte
Figure 18-15 Programming Flowchart
591
Write data to flash memory (flash
memory latches write address
and data)
*
1
Start
n = 1
Enable watchdog timer
Wait initial value setting x = 15
µ
s
*
2
Select program mode
(P bit = 1 in FLMCR)
Wait (x)
µ
s
Clear P bit
Disable watchdog timer
Select program-verify mode
(PV bit = 1 in FLMCR)
Wait (t
VS1
)
µ
s
Verify (read memory)
*
3
No good
OK
Clear PV bit
End (1-byte data programmed)
Programming ends
Clear PV bit
Programming error
n
≥
N?
n + 1
Double the programming
time (x
×
2
→
x)
→
n
No
Yes
Verify ends
Set erase block register
(set bit of block to be programmed to 1)
Wait (z)
µ
s
V E
PP
Clear bit
Clear erase block register
(clear bit of programmed block to 0)
V E
PP
Clear bit
Set V E bit
(V E bit = 1 in FLMCR)
PP
Clear erase block register
(clear bit of block to be
programmed to 0)
PP
Notes: 1. Write the data to be programmed using a
byte transfer instruction.
2. Set the watchdog timer overflow interval
by setting CKS2 and CKS1 to 0 and
CKS0 to 1.
3. Read to verify data from the memory
using a byte transfer instruction.
4. t
VS1
: 4 µs
z:
5 to 10 µs
N:
6 (set N so that total programming
time does not exceed 1 ms)
5. Programming time x, which is determined
by the initial time
×
2
n–1
(n = 1 to 6),
increases in proportion to n. Thus, set the
initial time to 15.8 µs or less to make total
programming time 1 ms or less.
www.DataSheet4U.com