
Rev. 2.0, 09/02, page 588 of 732
START
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
998
999
1000
t
sp
30
t
sp
30
t
sp
30
t
sp
30
t
sp
30
t
sp
30
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
t
sp
200
NG
NG
NG
NG
OK
OK
OK
*
2
*
7
*
7
*
4
*
7
*
7
*
5
*
7
*
7
*
1
*
4
*
3
*
7
*
7
*
7
*
1
*
4
OK
NG
OK
NG
OK
RAM
End of programming
Set SWE bit in FLMCR1
Start of programming
Wait (t
sswe
)
μ
s
n = 1
m = 0
Wait (t
spv
)
μ
s
Wait (t
spvr
)
μ
s
Wait (t
cpv
)
μ
s
Apply
Write Pulse (tsp30 or tsp200)
Sub-Routine-Call
Set PV bit in FLMCR1
H'FF dummy write to verify address
Read verify data
Write data =
verify data
Transfer reprogram data to reprogram data area
Reprogram data computation
Transfer additional-programming data to
additional-programming data area
Additional-programming data computation
Clear PV bit in FLMCR1
Clear SWE bit in FLMCR1
m = 1
Reprogram
See note *6 for pulse width
m = 0
Increment address
Programming failure
Clear SWE bit in FLMCR1
Wait (t
cswe
)
μ
s
6
≥
n
6
≥
n
Wait (t
cswe
)
μ
s
n
≥
N
n
←
n + 1
Store 128-byte program data in program
data area and reprogram data area
Apply Write Pulse (tsp10) (Additional programming)
128-byte
data verification completed
Successively write 128-byte data from additional-
programming data area in RAM to flash memory
Perform programming in the erased state.
Do not perform additional programming
on previously programmed addresses.
Original Data
(D)
0
Verify Data
(V)
0
Reprogram Data
(X)
1
Comments
Programming completed
Still in erased state; no action
Programming incomplete;
reprogram
Reprogram Data Computation Table
Reprogram Data
(X')
0
Verify Data
(V)
0
Additional-
Programming Data
(Y)
0
1
1
1
1
0
1
0
1
1
Comments
Additional programming
to be executed
Additional programming
not to be executed
Additional programming
not to be executed
Additional programming
not to be executed
0
1
1
1
0
1
0
1
1
Additional-Programming Data Computation Table
Notes: 1. Data transfer is performed by byte transfer. The lower 8 bits of the start address to be written to must be H'00 or H'80.
A 128-byte data transfer must be performed even if writing fewer than 128 bytes; in this case, H'FF data must be written to the extra addresses.
2. Verify data is read in 32-bit (longword) units.
3. Reprogram data is determined by the operation shown in the table below (comparison between the data stored in the program data area and the verify data). Bits for
which the reprogram data is 0 are programmed in the next reprogramming loop. Therefore, even bits for which programming has been completed will be subjected to
programming once again if the subsequent verify operation ends in failure.
4. A 128-byte area for the storage of programming data, a 128-byte area for the storage of reprogramming data, and a 128-byte area for the storage of additional-
programming data must be provided in RAM. The contents of the reprogram data area and additional-program data area are modified as programming proceeds.
5. A write pulse of 30
μ
s or 200
μ
s is applied according to the progress of the programming operation. See note 6 for details of the pulse widths. When writing of
additional-programming data is executed, a 10
μ
s write pulse should be applied. Reprogram data X' means reprogram data when the write pulse is applied.
7. The wait times and value of N are shown in section 26.5, Flash Memory Characteristics.
Program data storage
area (128 bytes)
Reprogram data storage
area (128 bytes)
Additional-programming
data storage area
(128 bytes)
Number of Writes n
Note: 6. Write Pulse Width
Write Time (tsp)
μ
s
*
Use a
t
sp
10 write pulse for additional programming.
Write pulse application subroutine
Apply Write Pulse
Set PSU bit in FLMCR1
Enable WDT
Disable WDT
Wait (t
spsu
)
μ
s
Set P bit in FLMCR1
Wait (tsp10, tsp30, or tsp200)
μ
s
Clear P bit in FLMCR1
Wait (t
cp
)
μ
s
Clear PSU bit in FLMCR1
Wait (t
cpsu
)
μ
s
Start of programming
End of programming
*
7
Successively write 128-byte data from reprogram
data area in RAM to flash memory
Figure 19.9 Program/Program-Verify Flowchart