Information
dsPIC33F/PIC24H PROGRAMMING SPECIFICATION
DS70152H-page 50 © 2010 Microchip Technology Inc.
6.0 PROGRAMMING THE
PROGRAMMING EXECUTIVE
TO MEMORY
6.1 Overview
If it is determined that the programming executive is not
present in executive memory (as described in
Section 3.2 “Confirming the Presence of the
Programming Executive”), it must be programmed
into executive memory using ICSP, as described in
Section 5.0 “Device Programming – ICSP”.
Storing the programming executive to executive
memory is similar to normal programming of code
memory. Namely, the executive memory must first be
erased, and then the programming executive must be
programmed 64 words at a time. This control flow is
summarized in Table 6 - 1 .
Note: The programming executive must
always be erased before it is
programmed, as described in Ta b l e 6-1.
TABLE 6-1: PROGRAMMING THE PROGRAMMING EXECUTIVE
Command
(Binary)
Data
(Hex)
Description
Step 1: Exit the Reset vector and erase executive memory.
0000
0000
0000
040200
040200
000000
GOTO 0x200
GOTO 0x200
NOP
Step 2: Initialize the NVMCON to erase a page of executive memory.
0000
0000
24042A
883B0A
MOV #0x4042, W10
MOV W10, NVMCON
Step 3: Initiate the erase cycle, wait for erase to complete and make sure WR bit is clear.
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
—
0000
0000
0000
0001
200080
880190
200001
000000
BB0881
000000
000000
A8E761
000000
000000
000000
000000
—
803B00
883C20
000000
<VISI>
MOV #0x80, W0
MOV W0, TBLPAG
MOV #0x00, W1
NOP
TBLWTL W1, [W1]
NOP
NOP
BSET NVMCON, #15
NOP
NOP
NOP
NOP
Externally time ‘P12’ msec (see Section 8.0 “AC/DC Characteristics and
Timing Requirements”) to allow sufficient time for the Page Erase operation to
complete.
MOV NVMCON, W0
MOV W0, VISI
NOP
Clock out contents of VISI register. Repeat instruction until the WR bit is clear.
Step 4: Repeat Step 3 to erase all pages of executive memory (incrementing the page erase pointer, i.e., W1 pointer
should be incremented by 0x400 to point to the second page).
Step 5: Initialize the NVMCON to program 64 instruction words.
0000
0000
24001A
883B0A
MOV #0x4001, W10
MOV W10, NVMCON
Step 6: Initialize TBLPAG and the write pointer (W7).
0000
0000
0000
0000
200800
880190
EB0380
000000
MOV #0x80, W0
MOV W0, TBLPAG
CLR W7
NOP