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

int32 address eeprom save using i2c

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







int32 address eeprom save using i2c
PostPosted: Wed Sep 23, 2009 12:54 am     Reply with quote

hello everybody, i have a code here that writes and reads data from an external eeprom(24fc1025).

Code:

void write_ext_eeprom(unsigned int32 address, BYTE data)
{
   short int status;
   i2c_start();
   i2c_write(0xa0);
   i2c_write(address>>8);
   i2c_write(address);
   i2c_write(data);
   i2c_stop();
   i2c_start();
   status=i2c_write(0xa0);
   while(status==1)
   {
      i2c_start();
      status=i2c_write(0xa0);
   }
   i2c_stop();
}

BYTE read_ext_eeprom(unsigned int32 address)
{
   BYTE data;
   i2c_start();
   i2c_write(0xa0);
   i2c_write(address>>8);
   i2c_write(address);
   i2c_start();
   i2c_write(0xa1);
   data=i2c_read(0);
   i2c_stop();
   return(data);
}

the problem is that if i write in an address that is beyond 65535, it goes back to the zero address and overwrites the data starting at the beginning. i already changed the parameters to int32 in my read_ext_eeprom and write_ext_eeprom but it still doesnt solve it.. can anybody here tell me whats wrong with my code? thanks in advance and god bless
[/quote]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 23, 2009 1:21 am     Reply with quote

CCS has a driver for this eeprom. You should use it:
Quote:
c:\program files\picc\drivers\241025.c

It does the addressing correctly.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Sep 23, 2009 1:49 am     Reply with quote

In addition, you may want to read about the block select bit in 24LC1025 data sheet.
X!nDy
Guest







PostPosted: Wed Sep 23, 2009 2:20 am     Reply with quote

thanks you for all your answers.. i really appreciate it. :D
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