2004 Microchip Technology Inc.
Advance Information
DS70119B-page 45
dsPIC30F6010
6.6
Programming Operations
A complete programming sequence is necessary for
programming or erasing the internal Flash in RTSP
mode. A programming operation is nominally 2 msec in
duration and the processor stalls (waits) until the oper-
ation is finished. Setting the WR bit (NVMCON<15>)
starts the operation, and the WR bit is automatically
cleared when the operation is finished.
6.6.1
PROGRAMMING ALGORITHM FOR
PROGRAM FLASH
The user can erase or program one row of program
Flash memory at a time. The general process is:
1.
Read one row of program Flash (32 instruction
words) and store into data RAM as a data
“image”.
2.
Update the data image with the desired new
data.
3.
Erase program Flash row.
a)
Setup NVMCON register for multi-word,
program Flash, erase, and set WREN bit.
b)
Write address of row to be erased into
NVMADRU/NVMDR.
c)
Write ‘55’ to NVMKEY.
d)
Write ‘AA’ to NVMKEY.
e)
Set the WR bit. This will begin erase cycle.
f)
CPU will stall for the duration of the erase
cycle.
g)
The WR bit is cleared when erase cycle
ends.
4.
Write 32 instruction words of data from data
RAM “image” into the program Flash write
latches.
5.
Program 32 instruction words into program
Flash.
a)
Setup NVMCON register for multi-word,
program Flash, program, and set WREN
bit.
b)
Write ‘55’ to NVMKEY.
c)
Write ‘AA’ to NVMKEY.
d)
Set the WR bit. This will begin program
cycle.
e)
CPU will stall for duration of the program
cycle.
f)
The WR bit is cleared by the hardware
when program cycle ends.
6.
Repeat steps 1 through 5 as needed to program
desired amount of program Flash memory.
6.6.2
ERASING A ROW OF PROGRAM
MEMORY
Example 6-1 shows a code sequence that can be used
to erase a row (32 instructions) of program memory.
EXAMPLE 6-1:
ERASING A ROW OF PROGRAM MEMORY
; Setup NVMCON for erase operation, multi word write
; program memory selected, and writes enabled
MOV
#0x4041,W0
;
MOV
W0
,
NVMCON
; Init NVMCON SFR
; Init pointer to row to be ERASED
MOV
#tblpage(PROG_ADDR),W0
;
MOV
W0
,
NVMADRU
; Initialize PM Page Boundary SFR
MOV
#tbloffset(PROG_ADDR),W0
; Intialize in-page EA[15:0] pointer
MOV
W0, NVMADR
; Intialize NVMADR SFR
DISI
#5
; Block all interrupts with priority <7
; for next 5 instructions
MOV
#0x55,W0
MOV
W0
,
NVMKEY
; Write the 0x55 key
MOV
#0xAA,W1
;
MOV
W1
,
NVMKEY
; Write the 0xAA key
BSET
NVMCON,#WR
; Start the erase sequence
NOP
; Insert two NOPs after the erase
NOP
; command is asserted
Summary of Contents for dsPIC30F6010
Page 12: ...dsPIC30F6010 DS70119B page 10 Advance Information 2004 Microchip Technology Inc NOTES...
Page 32: ...dsPIC30F6010 DS70119B page 30 Advance Information 2004 Microchip Technology Inc NOTES...
Page 38: ...dsPIC30F6010 DS70119B page 36 Advance Information 2004 Microchip Technology Inc NOTES...
Page 50: ...dsPIC30F6010 DS70119B page 48 Advance Information 2004 Microchip Technology Inc NOTES...
Page 68: ...dsPIC30F6010 DS70119B page 66 Advance Information 2004 Microchip Technology Inc NOTES...
Page 72: ...dsPIC30F6010 DS70119B page 70 Advance Information 2004 Microchip Technology Inc NOTES...
Page 76: ...dsPIC30F6010 DS70119B page 74 Advance Information 2004 Microchip Technology Inc NOTES...
Page 86: ...dsPIC30F6010 DS70119B page 84 Advance Information 2004 Microchip Technology Inc NOTES...
Page 108: ...dsPIC30F6010 DS70119B page 106 Advance Information 2004 Microchip Technology Inc NOTES...
Page 116: ...dsPIC30F6010 DS70119B page 114 Advance Information 2004 Microchip Technology Inc NOTES...
Page 128: ...dsPIC30F6010 DS70119B page 126 Advance Information 2004 Microchip Technology Inc NOTES...
Page 150: ...dsPIC30F6010 DS70119B page 148 Advance Information 2004 Microchip Technology Inc NOTES...
Page 164: ...dsPIC30F6010 DS70119B page 162 Advance Information 2004 Microchip Technology Inc NOTES...
Page 208: ...dsPIC30F6010 DS70119B page 206 Advance Information 2004 Microchip Technology Inc NOTES...
Page 220: ...dsPIC30F6010 DS70119B page 220 Advance Information 2004 Microchip Technology Inc NOTES...
Page 221: ...2004 Microchip Technology Inc Advance Information DS70119B page 221 dsPIC30F6010 NOTES...