UM10208_2
© NXP B.V. 2007. All rights reserved.
User manual
Rev. 02 — 1 June 2007
32 of 362
NXP Semiconductors
UM10208
Chapter 5: LPC2800 Flash
7. Restoring protection to sectors that have been operated upon
These steps are described in more detail in the following sections.
4.2 Sector protection and un-protection
A sector is unprotected by writing an even value to its base address (the starting address
of the sector), followed by writing the unprotect trigger value to the F_CTRL register. The
trigger value for (un)protecting has the following bits set: FC_LOAD_REQ,
FC_PROTECT, FC_WEN, FC_FUNC, and FC_CS. The other bits are zero.
A sector is protected by writing an odd value to its base address, followed by the same
trigger value that was used to unprotect the sector.
4.3 Erasing sectors
First, a sector to be erased must be unprotected as described above. Before the erasing,
the erase time must be selected in the timer register FPT_TIME field of the
F_PROG_TIME register, and the timer must be enabled via the FPT_ENABLE field of the
in the same register. During erasing, the timer register counts down to zero. Therefore, the
timer register must be rewritten prior to every erase cycle.
The programmed erase time must satisfy the requirement:
(512
×
FP 2)
×
(AHB clock time)
≥
400ms
Which is to say, write FPT_TIME with the integer greater than or equal to:
((400,000,000 / AHB t
cyc
(in ns)) - 2) / 512
A single sector is erased by writing any value to an address within that sector, followed by
writing the erase trigger value to the F_CTRL register. The trigger value for erasing has
the following bits set: FC_PROG_REQ, FC_PROTECT, and FC_CS. The other bits are
zero.
For erasing and other programming operations, the Flash module needs a 66 kHz clock.
This clock is derived from the AHB clock, dividing it by a factor programmed in the
CLK_DIV field of the F_CLK_TIME register. A value of zero in this field inactivates the
FLASH PROGRAMMING clock.
Erasing multiple sectors can be done with only one longer erase cycle. First all sectors
except the last are selected for erasure. Then the last sector is erased using the single
sector erase procedure. A sector is selected for erasure by writing any value to an
address within that sector, followed by writing the select for erase trigger value to the
F_CTRL register. This trigger value has the following bits set: FC_LOAD_REQ,
FC_PROTECT, FC_WEN, and FC_CS. The other bits are zero.
The Flash controller can optionally generate an interrupt request when erasing is finished,
otherwise the FS_DONE flag in the F_STAT register can be polled by software to
determine when erasure is complete.