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 16bit using WRITE_EXT_EEPROM( address, value );

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








How to write 16bit using WRITE_EXT_EEPROM( address, value );
PostPosted: Wed Oct 06, 2004 10:55 am     Reply with quote

hi there.

i'm currently looking on WRITE_EXT_EEPROM( address, value );
what i want to do is store 16bit value into my eeprom.how can i do that?.
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Wed Oct 06, 2004 11:28 am     Reply with quote

You can save two bytes in sequence! One in each address!
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Oct 06, 2004 2:03 pm     Reply with quote

Saving each byte in sequences all you get is two consecutive bytes stored in external EEPROM,
to affect the whole number to be able to operate arithmetically you need to create a struct.

Code:


#define addr_varH              0x1000
#define addr_varL     addr_varH + 1

struct BigVar{
int8  varL;
int8  varH;
          };

union store{
long  WordValue;
struct BigVar  double_var;
           }Stuff;

// to access a byte:

    varH = read_ext_eeprom(addr_varH);
    varL = read_ext_eeprom(addr_varL);

// to write a byte:

    write_ext_eeprom(addr_varH, Stuff.double_var.H);
    write_ext_eeprom(addr_varL, Stuff.double_var.L);

// to modify the whole number:

   WordValue += 1;
 


Best wishes,

Humberto
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed Oct 06, 2004 6:02 pm     Reply with quote

Also take a look at CCS' official FAQ on this subject...here:

http://www.ccsinfo.com/faq/?24
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