
23
www.national.com
tially within one single high voltage pulse. This is supported
through a double-buffered write-data buffer scheme. Byte
programming is not supported. Programming should be
done on erased rows.
A page erase requires the following code sequence (assum-
ing that this sequence will not be interrupted to do another
flash erase or programming):
1. Check for MSTAT.PGMBUSY not set.
2. Set FLCSR.ERASE = 1.
3. If interrupt was enabled, disable interrupt.
4. Write proper key value to PGMKEY.
5. Write to any valid location within the page to be erased.
6. If interrupt was disabled in step 3, re-enable interrupt.
7. Set FLCSR.ERASE = 0.
When programming, the data to be written into the flash EE-
PROM program memory is first written into a double-buffered
write-data buffer. When a piece of data is written to the page
while the flash EEPROM program memory is idle, the write
cycle will start. Due to the double-buffered nature of the
write-data buffer, a second word can be written to the flash
EEPROM program memory. This will then set FLCSR.PML-
FULL flag indicating the buffer is now full. When the first
write is done, the memory address would be incremented,
and the second word would be written to that address while
keeping the high voltage pulse active; the FLCSR.PMLFULL
flag is cleared.
Another word can then be written to the buff-
er, and this programming will repeat until there are no more
words to be programmed. This allows pipelined writes to dif-
ferent words on the same row within the same high voltage
pulse. If the programming sequence exceeds a row, the
flash programming interface will automatically initiate a pro-
gramming pulse for the next row. The FLCSR.PMLFULL bit
is also cleared. when programming of the last word of the
current row is completed, e.g. programming of the entire row
is completed and MSTAT.PGMBUSY is cleared. This means,
the separation of the program memory into rows is transpar-
ent to the user, as the transition is handled by the flash pro-
gram memory interface. Figure2 shows a flowchart for a
programming sequence.
Erase Procedure
Erasing a page requires the following code sequence:
1. Verify that the MSTAT.PGMBUSY bit is cleared.
2. Disable any enabled interrupts.
3. Set the FLCSR.ERASE bit to 1.
4. Write the proper key value to the PGMKEY register.
5. Write to any valid location in the page to be erased.
6. Clear the FLCSR.ERASE bit to 0.
7. Re-enable any interrupts disabled in Step 2.
Erased bits read back as 1.
start
MSTAT.PGMBUSY
=1
disable interrupt
if necessary
write PGMKEY
re-enable interrupt
if necessary
write memory
last word
done
Yes
No
Yes
Yes
FLCSR.PMLFULL
=0
No
No
Figure 2.
Programming Sequence for
the Program Memory