|
|
View previous topic :: View next topic |
Author |
Message |
pokiko
Joined: 27 Jul 2007 Posts: 33
|
writing zeros to program eeprom initially |
Posted: Tue Jun 24, 2008 10:00 am |
|
|
hi
i am using pic16F877A with
Code: |
#fuses HS, NOWDT, NOPUT, PROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=16000000)
|
i want to initially write 720 words of 0 'zero' to program eeprom by command write_program_eeprom().
i have tried it such as below but i have failed.
Code: |
for (k=0;k<720<k++)
{
write_program_eeprom(k,0);
}
|
i've looked at the help file but i couldn't understand how can i write to it before main.
is there such a way to achieve this?
thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 24, 2008 11:21 am |
|
|
Quote: | for (k=0;k<720<k++)
{
write_program_eeprom(k,0);
} |
Where do you think that code is located ? Look at the .LST file.
Look at the address of that code. Also look at the code at ROM address
0x0000 in the .LST file.
That code will likely wipe out itself, while it is only partially done with
executing the loop count. Also, that code will wipe out the Reset Vector
and Interrupt Vector code.
You could relocate the main() code with an #org statement, but you
will still wipe out the Reset Vector and Interrupt Vector code. The
16F877A will always jump to 0x0000 upon reset. It will always jump
to 0x0004 when it gets an interrupt. If there is no code (even a jump)
at those locations, then the program will crash. |
|
|
Franck26
Joined: 29 Dec 2007 Posts: 122 Location: Ireland
|
|
Posted: Wed Jun 25, 2008 3:56 pm |
|
|
If you want to write the data into the EEPROM during the programming of your chip, you can use:
Code: | #ROM EEPROM_ADD={1,2,3,4,5} |
With EEPROM_ADD the start address of your EEPROM.
Franck. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|