To erase a sector or bank of the flash
memory, follow these steps:
- Select the command in the CMDTYPE register:
- Set the COMMAND field in the CMDTYPE register to ERASE.
- Set the SIZE field in the CMDTYPE register to SECTOR or BANK. Sizes
other than SECTOR or BANK (for example, ONEWORD) are not supported by the
ERASE command. It is the responsibility of software to check the
configuration before issuing an ERASE command.
- Select the target erase address in the CMDADDR register:
- Store the target
system address into the CMDADDR register to indicate the base
address of the sector or bank to be erased. When performing a bank
erase with write protection enabled (such that only unprotected
sectors are erased), ensure that the address written to CMDADDR is
in an unprotected sector. The flash controller will translate the
system address into the applicable flash region, bank ID, and bank
address. If desired, after the operation completes the flash region,
bank ID, and bank address can be read from the STATADDR register.
- Ensure the write protection scheme is configured to allow writes to the target sectors (see the write
protection section of this guide for additional information on configuring write protection).
- Execute the erase operation by writing 0x1 to the CMDEXEC register.
- Monitor for completion of the erase operation:
- The STATCMD register can be polled to determine the status of the
erase operation. The CMDINPROGRESS bit will be set by hardware as
soon as the command is initiated. The CMDDONE bit will be set when
the operation terminates. When CMDDONE is set, the CMDPASS bit will
be reset or set at the same time to indicate whether the operation
completed successfully or failed.
- If an erase was attempted on a protected region, the FAILWEPROT bit
is asserted.
- If the erase operation cannot be completed successfully within the
maximum erase pulse count limit, FAILVERIFY will be asserted.
- After completion of the erase operation, the flash controller will configure
several settings to protect against inadvertent programming:
- All dynamic write protection registers are set to a protected state.