Erasing Program Flash Memory (PFM)

The minimum erase block is always one sector. Only through the use of an external programmer, or through ICSP™ control, can larger blocks of program memory be Bulk Erased. Word erase in the Flash array is not supported.

For example, when initiating an erase sequence from a microcontroller with sector erase size of 128 words, a block of 128 words (256 bytes) of program memory is erased. The NVMADR[21:8] bits point to the block being erased. The NVMADR[7:0] bits are ignored.

The NVMCON0 and NVMCON1 registers command the erase operation. The NVMEN bit must be set to enable write operations. The SECER bit is set to initiate the erase operation.

The NVM unlock sequence described in the NVM Unlock Sequence section must be used, which guards against accidental writes. This is sometimes referred to as a long write.

A long write is necessary for erasing the internal Flash. Instruction execution is halted during the long write cycle. The long write is terminated by the internal programming timer.