18.7.1 Program Mode
To write data into the flash memory, follow the programming algorithm shown in figure 18-15.
This programming algorithm can write data without subjecting the device to voltage stress or
impairing the reliability of programmed data.
To program data, first set the V
PP
E bit in FLMCR, wait 5 to 10 µs, then designate the blocks to be
programmed by erase block registers 1 and 2 (EBR1, EBR2), and write the data to the address to
be programmed, as in writing to RAM. The flash memory latches the address and data in an
address latch and data latch. Next set the P bit in FLMCR, selecting program mode. The
programming duration is the time during which the P bit is set. A software timer should be used to
provide an initial programming duration of 15.8 µs or less. Programming for too long a time, due
to program runaway for example, can cause device damage. Before selecting program mode, set
up the watchdog timer so as to prevent overprogramming.
18.7.2 Program-Verify Mode
In program-verify mode, after data has been programmed in program mode, the data is read to
check that it has been programmed correctly.
After the programming time has elapsed, exit programming mode (clear the P bit to 0) and select
program-verify mode (set the PV bit to 1). In program-verify mode, a program-verify voltage is
applied to the memory cells at the latched address. If the flash memory is read in this state, the
data at the latched address will be read. After selecting program-verify mode, wait 4 µs before
reading, then compare the programmed data with the verify data. If they agree, exit program-
verify mode and program the next address. If they do not agree, select program mode again and
repeat the same program and program-verify sequence. Do not repeat the program and program-
verify sequence more than 6 times for the same bit. (When a bit is programmed repeatedly, set a
loop counter so that the total programming time will not exceed 1 ms.)
590
www.DataSheet4U.com