
385
SAM G51 [DATASHEET]
11209C–ATARM–20-Dec-13
Figure 19-10. Programming Bytes in the Flash
19.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.
32 bits wide
FF
0xX00
0xX04
0xX08
0xX0C
0xX10
0xX14
0xX18
0xX1C
FF
address space
for
Page N
Step 1: Flash array after programming first byte (0xAA)
64-bit used at address 0xX00 (write latch buffer + WP)
FF
xx
AA
32 bits wide
FF
0xX00
0xX04
0xX08
0xX0C
0xX10
0xX14
0xX18
0xX1C
FF
xx
AA
Step 2: Flash array after programming second byte (0x55
64-bit used at address 0xX08 (write latch buffer + WP)
xx
55
Note: The byte location shown here is for example only, it can be any byte location within a 64-bit word.
4 x 32 bits =
1 Flash word
4 x 32 bits =
1 Flash word
Note:
If one subsector is locked within the first sector, the erase sector (ES) command cannot be
processed on non-locked subsectors of the first sector. All the lock bits of the first sector
must be cleared prior to issuing an ES command on the first sector. After the ES command
has been issued, the first sector lock bits must be reverted to the state before clearing them.