360
SAM4CP [DATASHEET]
43051E–ATPL–08/14
22.4.3.3 Erase Commands
Erase commands are allowed only on unlocked regions. Depending on the Flash memory, several commands can be
used to erase the Flash:
Erase all memory (EA): all memory is erased. The processor must not fetch code from the Flash memory.
Erase pages (EPA): 8 or 16 pages are erased in the Flash sector selected.The first page to be erased is specified
in the FARG[15:2] field of the MC_FCR. The first page number must be modulo 8,16 or 32 depending on the
number of pages to erase at the same time.
Erase Sector (ES): a full memory sector is erased. Sector size depends on the Flash memory. FARG must be set
with a page number that is in the sector to be erased.
If the processor is fetching code from the Flash memory while the EPA or ES command is being performed, the
processor accesses will be stalled until the EPA command is completed. To avoid stalling the processor, the code can be
run out of internal SRAM.
The erase sequence is:
1.
Erase starts as soon as one of the erase commands and the FARG field are written in EEFC_FCR.
For the EPA command, the two lowest bits of the FARG field define the number of pages to be erased
(FARG [1:0]):
2.
When programming is completed, the bit EEFC_FSR.FRDY rises. If an interrupt has been enabled by setting the
bit EEFC_FMR.FRDY, the interrupt line of the interrupt controller is activated.
Three errors can be detected in EEFC_FSR after a programming sequence:
Command Error: a bad keyword has been written in EEFC_FCR.
Lock Error: at least one page to be erased belongs to a locked region. The erase command has been refused, no
page has been erased. A command must be run previously to unlock the corresponding region.
Flash Error: at the end of the programming, the EraseVerify test of the Flash memory has failed.
22.4.3.4 Lock Bit Protection
Lock bits are associated with several pages in the embedded Flash memory plane. This defines lock regions in the
embedded Flash memory plane. They prevent writing/erasing protected pages.
The lock sequence is:
1.
The Set lock bit (SLB) command and a page number to be protected are written in EEFC_FCR.
2.
When the locking completes, the bit EEFC_FSR.FRDY rises. If an interrupt has been enabled by setting the bit
EEFC_FMR.FRDY, the interrupt line of the interrupt controller is activated.
3.
The result of the SLB command can be checked running a Get Lock Bit (GLB) command.
Note:
The value of the FARG argument passed together with SLB command must not exceed the higher lock bit index
available in the product.
Two errors can be detected in EEFC_FSR after a programming sequence:
Command Error: a bad keyword has been written in EEFC_FCR.
Flash Error: at the end of the programming, the EraseVerify or WriteVerify test of the Flash memory has failed.
Table 22-4.
FARG Field for EPA command
FARG[1:0]
Number of pages to be erased with EPA command
0
4 pages (only valid for small 8 kB sectors)
1
8 pages
2
16 pages
3
32 pages (only valid for small 8 kB sectors)