9 Erasing the Device
Before a device can be programmed, it must be erased. The erase operation writes all
‘1
s’ to the Flash memory and prepares it to program a new set of data. Once
a device is erased, it can be verified by performing a “Blank Check” operation. See Blank Check for more information.
The procedure for erasing program memory (program, boot, and configuration memory) consists
of selecting the MTAP and sending the
MCHP_ERASE
command. The programmer must
wait for the erase operation to complete by reading and verifying bits in the
MCHP_STATUS
value. Figure 9-1 illustrates the process for performing a chip erase operation.Note: The device ID memory locations are read-only
and cannot be erased. Therefore, the chip erase operation has no effect on these memory
locations.
The following steps are required to erase a target device:
SendCommand (MTAP_SW_MTAP)
.- SetMode
(6’b011111)
. SendCommand (MTAP_COMMAND)
.- XferData
(MCHP_ERASE)
. - XferData
(MCHP_DE_ASSERT_RST)
.Note: This step is not required for the PIC32MX devices. - Delay 10 ms.
- statusVal = XferData
(MCHP_STATUS)
. - If CFGRDY (statusVal[3]) is not
‘
1
’ and FCBUSY (statusVal[2]) is not ‘0
’, go to step 5.noteNote: The Chip Erase operation is a self-timed operation. If the FCBUSY and CFGRD bits do not set properly within the specified Chip Erase time, the sequence may have been executed incorrectly or the device is damaged.