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

how to write/read 16 bit data to internal eeprom

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



Joined: 04 Jun 2006
Posts: 35

View user's profile Send private message

how to write/read 16 bit data to internal eeprom
PostPosted: Wed Sep 13, 2006 5:01 am     Reply with quote

hi:

i can write 8 bit date like ;

write_eeprom(0x00,volume);

but i could not write 16 bit data...

could you help me?
Ttelmah
Guest







PostPosted: Wed Sep 13, 2006 5:18 am     Reply with quote

16 bit data, is just two 8 bit bytes (this is how the processor stores it anyway). Look at the make8, and make16 functions (which allow the bytes to be seperated and rejoined).
An example of a generic 'bigger I/O' function, would be:
Code:

void write_eeprom_block(int16 ROM_addr, int8 * addr, int8 number_of_bytes) {
   int8 ctr;
   for (ctr=0;ctr<number_of_bytes;ctr++) {
      write_eeprom(ROM_addr++,*(addr++));
   }
}

//For your 'int16' volume value, call with:

write_eeprom_block(0x00,&volume,sizeof(volume));

The nice thing about this, is that the same function, will handle int32, int16, float etc..

Best Wishes
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