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

Store/read structure to/from eeprom...

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








Store/read structure to/from eeprom...
PostPosted: Sat May 29, 2004 9:27 am     Reply with quote

I´m trying to write a struct that will "live" in eeprom, will be loaded from eeprom and stored sometimes.

struct eeprom {
int8 table1[64];
int8 table2[64];
int8 table3[64];

int8 speed;
int8 load; ...
...32 config bytes
};

struct eeprom config;

where I´m stuck is at using pointers to access data in the struct.

int16 pointer;
for (index=0;index<=160;index++) {
eeprom_write(..config..don´t know how to access); //write or read
delay_ms(10); // let write cycle to end
}
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

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

PostPosted: Sat May 29, 2004 10:28 am     Reply with quote

how about this:

Code:

int8 *pointer;
int8 index;
int8 eeprom_address=0;

pointer=&config;

for (index=0;index<=sizeof(config);index++) {
  eeprom_write(eeprom_address++,*pointer);
  pointer++;
}


Also, I don't think you need the delay... I think eeprom_write() will wait until the last write cycle ended.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Sat May 29, 2004 2:34 pm     Reply with quote

And how about accessing bits individually? like config.speed.bit0..bit7

bit_test(config.speed,0) ?
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