Erase Commands

Erase commands are allowed only on unlocked regions. Depending on the Flash memory, several commands can be used to erase the Flash:

Note: If one sub-sector is locked within the first sector, the Erase Sector (ES) command cannot be processed on non-locked sub-sectors 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.

If the processor is fetching code from the Flash memory while the EPA or ES command is being executed, the processor accesses are stalled until the EPA command is completed. To avoid stalling the processor, the code can be run out of internal SRAM.

The following are the erase sequence:

  1. 1.Erase starts immediately 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]), see table below.

    Table 1. EEFC_FCR.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 (only valid for small 8-KB sectors)
    2 16 pages
    3 32 pages (not valid for small 8-KB sectors)
  2. 2.When erasing is completed, the EEFC_FSR.FRDY bit rises. If an interrupt has been enabled by setting the EEFC_FMR.FRDY bit, the interrupt line of the interrupt controller is activated.

Three errors can be detected in EEFC_FSR after an erasing sequence: