Jumper
- 17th August 2006, 10:35
Hi,
This might seem as a strange thing to do but I want to write to the program memory i.e as a Bootloader would do. I have located my code so it will not be overwritten but I get some weird results. So i decided to try this simple code that is put away far from my target write adresses. All variables are defined as Words.
for i =0 to 31 step 2
flash=i
temp=$ABCD
WRITECODE flash,temp
next i
HSEROUT ["DONE",10,13]
pause 2000
stop
Every time I run it I get a small printout "DONE" . Then I readback the code into MPLAB using Programmer->READ and look in the Program Memory window. The thing is that I can write to ANY address and get the correct value stored EXCEPT if I write to adr $0000, $0002 and $0004. These adresses only accepts $0000 as value if they will store it right. If I use $ABCD as value it looks like this in the Program memory readback:
0000: 2A04
0002: AB40
0004: A044
0006: ABCD
and the rest are ABCD as expected.
Other values give similar results and sometimes adr $0004 reads back OK but never 0000 and 0002 if I don't write 0000 to them.
Anyone? Any guess?
The PIC is a 18F4620 and no code protection and Tablewrite fuses are OFF. Neither manual (PBP or 18F4620) mentions anything about this from what I can see.
This is killing my project for the moment, I would be very happy if someone could come up with any ideas and answers.
I also printed the values stright from the PIC using READCODE and they show the same as MPLAB, so it is not a MPLAB problem!
best regards
/me
This might seem as a strange thing to do but I want to write to the program memory i.e as a Bootloader would do. I have located my code so it will not be overwritten but I get some weird results. So i decided to try this simple code that is put away far from my target write adresses. All variables are defined as Words.
for i =0 to 31 step 2
flash=i
temp=$ABCD
WRITECODE flash,temp
next i
HSEROUT ["DONE",10,13]
pause 2000
stop
Every time I run it I get a small printout "DONE" . Then I readback the code into MPLAB using Programmer->READ and look in the Program Memory window. The thing is that I can write to ANY address and get the correct value stored EXCEPT if I write to adr $0000, $0002 and $0004. These adresses only accepts $0000 as value if they will store it right. If I use $ABCD as value it looks like this in the Program memory readback:
0000: 2A04
0002: AB40
0004: A044
0006: ABCD
and the rest are ABCD as expected.
Other values give similar results and sometimes adr $0004 reads back OK but never 0000 and 0002 if I don't write 0000 to them.
Anyone? Any guess?
The PIC is a 18F4620 and no code protection and Tablewrite fuses are OFF. Neither manual (PBP or 18F4620) mentions anything about this from what I can see.
This is killing my project for the moment, I would be very happy if someone could come up with any ideas and answers.
I also printed the values stright from the PIC using READCODE and they show the same as MPLAB, so it is not a MPLAB problem!
best regards
/me