Atmel ARM-Based Evaluation Kit for SAM4S16C, 32-Bit ARM® Cortex® Microcontroller ATSAM4S-WPIR-RD ATSAM4S-WPIR-RD Data Sheet

Product codes
ATSAM4S-WPIR-RD
Page of 1231
SAM4S Series [DATASHEET]
Atmel-11100G-ATARM-SAM4S-Datasheet_27-May-14
360
Figure 20-9.
Programming Bytes in the Flash 
20.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:
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]): 
32 bits wide
FF    FF    FF    FF
FF    FF    FF    FF
FF    FF    FF    FF
FF    FF    FF    FF
0xX00
0xX04
0xX08
0xX0C
0xX10
0xX14
0xX18
0xX1C
FF    FF    FF    FF
FF    FF    FF    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    FF    FF    FF
xx    xx    xx    xx
xx    xx    xx    AA
32 bits wide
FF    FF    FF    FF
FF    FF    FF    FF
FF    FF    FF    FF
FF    FF    FF    FF
0xX00
0xX04
0xX08
0xX0C
0xX10
0xX14
0xX18
0xX1C
FF    FF    FF    FF
xx    xx    xx    xx
xx    xx    xx    AA
Step 2: Flash array after programming second byte (0x55
 64-bit used at address 0xX08 (write latch buffer + WP)  
xx    xx    xx    xx
xx    xx    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
Table 20-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 (not valid for small 8 KB sectors)