2.5 Erasing Program Memory

Figure 2-5 shows a high-level overview of the Bulk Erase of code memory.

Table 2-4 provides the ICSP programming process for erasing the program memory.
Note: Program memory must be erased before writing any data to program memory.
Figure 2-5. Bulk Erase Flow
Table 2-4. Serial Instruction Execution for Bulk Erase of Code Memory
Command

(Binary)

Data

(Hex)

Description
Step 1: Exit the Reset vector.

0000

0000

0000

0000

0000

0000

0000

000000

000000

000000

040200

000000

000000

000000

NOP

NOP

NOP

GOTO 0x200

NOP

NOP

NOP

Step 2: Set the NVMCON register to erase all user program memory.

0000

0000

0000

0000

2400EA

88468A

000000

000000

MOV #0x400E, W10

MOV W10, NVMCON

NOP

NOP

Step 3: Initiate the erase cycle.

0000

0000

0000

0000

0000

0000

0000

0000

200551

8846B1

200AA1

8846B1

A8E8D1

000000

000000

000000

MOV #0x55, W1

MOV W1, NVMKEY

MOV #0xAA, W1

MOV W1, NVMKEY

BSET NVMCON, #WR

NOP

NOP

NOP

Step 4: Generate clock pulses for the code memory Bulk Erase operation to complete until the WR bit is cleared.

0000

0000

0000

0000

0000

0001

0000

0000

0000

0000

0000

0000

0000

000000

804680

000000

887E60

000000

<VISI>

000000

000000

000000

040200

000000

000000

000000

NOP

MOV NVMCON, W0

NOP

MOV W0, VISI

NOP

Clock out contents of the VISI register.

NOP

NOP

NOP

GOTO 0x200

NOP

NOP

NOP

Repeat until the WR bit is cleared.