6.5.7.1.7 Erase Memory
Erasing SRAM is equivalent to writing a block of data with the desired value using the Write SRAM procedure.
Erasing the entire Flash is performed through a Boot ROM Interactive mode command. Refer to the CMD_CE_ALL command in the Command CE_ALL section.
Erasing individual pages is performed through an NVM controller command.
| Steps | Commands |
|---|---|
| Enable the Erase Command | dap_write_word (NVMCTRL_CTRLB,
NVMCTRL_CMD_FLPER); |
| Set the Page Address | dap_write_word (NVMCTRL_ADDR,
page_addr); |
| Wait for Erase to complete | while (0 == (dap_read_word (NVMCTRL_INTFLAG) &
1)); |
| Disable the Erase Command | dap_write_word (NVMCTRL_CTRLB,
NVMCTRL_CMD_NOCMD); |
This sequence assumes that the page is not locked by LOCK fuses or BOOTPROT.
Relevant registers are:
- NVMCTRL_CTRLB
0x4100_4004 - NVMCTRL _INTFLAG
0x4100_4014 - NVMCTRL _ADDR
0x4100_4020
