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 support@ccsinfo.com

EEPROM write problems

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



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

EEPROM write problems
PostPosted: Tue May 08, 2007 12:34 am     Reply with quote

Hello Forum

I have a problem about writing int32 values to the internal EEPROM.
I use the ICD2 for debug and I can see that the "adr" and "data" is loaded correct, but after writing to EEPROM I can read the EEPROM and see that the data isen't there.

The code I use looks like this:

int32 data; // data to EEPROM
int8 adr; // adresse to EEPROM


void write_int32_eeprom(adr, int32 data) // rutine to write 32 bit
{ // remember to have 4 free
// EEPROM adresses over used
int8 i;

for (i = 0; i < 4; i++)

write_eeprom(i + adr, *(((int8*)&data) + i) ) ;

Can anyone tell what wrong?
(I'am new in C-programming)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 08, 2007 1:32 am     Reply with quote

Show the code that calls the write_int32_eeprom() function.
Show a few lines of it.
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Tue May 08, 2007 4:15 am     Reply with quote

Thanks for helping, but I think I now have found the problem.
The problem was that I don't should take variables to the write rutine because it's diffined as global variables. My write rutine should therefore look like this instead. Sorry of my bad knowledge of C yet.
(however I could see that you look for the same mistake)

void write_int32_eeprom() // rutine to write 32 bit
{ // remember to have 4 free
// EEPROM adresses over used
int8 i;

for (i = 0; i < 4; i++)

write_eeprom(i + adr, *(((int8*)&data) + i) ) ;
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