CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

writing zeros to program eeprom initially

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pokiko



Joined: 27 Jul 2007
Posts: 33

View user's profile Send private message Send e-mail

writing zeros to program eeprom initially
PostPosted: Tue Jun 24, 2008 10:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 24, 2008 11:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 25, 2008 3:56 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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