English
Language : 

PIC24F04KA200 Datasheet, PDF (9/26 Pages) Microchip Technology – Flash Programming Specifications
PIC24FXXKA2XX
3.5 Erasing Program Memory
To erase the program memory (all of code memory,
data memory and Configuration bits, including the
code-protect bits), set the NVMCON to 4064h and then
execute the programming cycle.
Figure 3-6 illustrates the ICSP programming process
for Bulk Erase. This process includes the ICSP
command code, which must be transmitted (for each
instruction), LSB first, using the PGCx and PGDx pins
(see Figure 3-2).
Table 3-4 provides the steps for executing serial
instruction for the Bulk Erase mode.
Note: Program memory must be erased before
writing any data to program memory.
FIGURE 3-6:
BULK ERASE FLOW
Start
Write 4064h to NVMCON SFR
Set the WR bit to Initiate Erase
Delay P11 + P10 Time
End
TABLE 3-4: SERIAL INSTRUCTION EXECUTION FOR CHIP ERASE
Command
(Binary)
Data
(Hex)
Description
Step 1: Exit the Reset vector.
0000
0000
0000
000000
040200
000000
NOP
GOTO
NOP
0x200
Step 2: Set the NVMCON to erase the entire program memory.
0000
0000
24064A
883B0A
MOV #0x4064, W10
MOV W10, NVMCON
Step 3: Set the TBLPAG and perform dummy table write to select the erased memory.
0000
0000
0000
0000
0000
0000
200000
880190
200000
BB0800
000000
000000
MOV #<PAGEVAL>, W0
MOV W0, TBLPAG
MOV #0x0000, W0
TBLWTL W0, [W0]
NOP
NOP
Step 4: Initiate the erase cycle.
0000
0000
0000
A8E761
000000
000000
BSET
NOP
NOP
NVMCON, #WR
Step 5: Repeat this step to poll the WR bit (bit 15 of NVMCON) until it is cleared by the hardware.
0000
0000
0000
0000
0000
0000
0001
0000
000000
040200
000000
803B02
883C22
000000
<VISI>
000000
NOP
GOTO 0x200
NOP
MOV NVMCON, W2
MOV W2, VISI
NOP
Clock out the contents of the VISI register.
NOP
 2010 Microchip Technology Inc.
DS39991A-page 9