6.1.8.1 Page Erase

A page erase performs an erase of a single page of the main program, boot/configuration or sector redundancy Flash. The page to be erased is selected using NVMADDR. The lower bits of the address given by NVMADDR are ignored in page selection. A page of flash can be erased if its associated page write protection is not enabled.

Follow this sequence of steps to erase a page:

  1. Set NVMADDR with the address of the page to be erased.
  2. Run the following unlock sequence using the page erase command to start the sequence:
    1. Set NVMCON.WREN = 1 (allow writes to NVMCON.NVMWR), and set NVMCON.NVMOP to PAGE_ERASE (using a single write).
    2. Set NVMKEY = 0x00000000 (reset key).
    3. Set NVMKEY = 0xAA996655.
    4. Set NVMKEY = 0x556699AA.
    5. Write to the target register NVMCONSET to set the NVMWR bit (not the NVMCON register itself). This begins the FC operation.
    Note: The erase sequence completes when the hardware clears the NVMCOM.NVMWR bit. This generates an interrupt.
  3. Clear the NVMCON.NVMWREN bit.
  4. Check the NVMCON.NVMERR and NVMCON.BORERR bits to ensure that the erase sequence completes successfully.