[PIC] dsPIC30F5013 ERASE PROGRAM MEMORY

Status
Not open for further replies.

Christian Zichichi

Newbie level 2
Joined
Jan 10, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
14
Hi,
I need to wipe the program memory entirely (all bits at 0) of my dsPIC30F5013,
why doesn't this code work?

oldAddress=0x100;
while(oldAddress<0x00AFFE){
addressToWrite=oldAddress;
if(oldAddress+16<=0x00AFFE)
break;
else
WriteWord(addressToWrite,0);
oldAddress+=16;
}


function WriteWord is defined in in eeprom_rw.s written by btbass (library included in the code):
;------ Write a word to eeprom
_WriteWord:
push w4
mov #ADDRESS_HI,w4
mov w4,TBLPAG
mov w4,NVMADRU
mov #ADDRESS_LO,w4
sl w0,#1,w0
add w0,w4,w0
mov w0,NVMADR
rcall EraseWord
mov #WRITE_WORD,w4
mov w4,NVMCON
TBLWTL w1,[w0]
rcall KeySequence
pop w4
return
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…