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

Microchip 24AA512 512k I2C EEPROM driver

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
UFAnders



Joined: 13 Apr 2005
Posts: 36
Location: Michigan

View user's profile Send private message Send e-mail Visit poster's website AIM Address

Microchip 24AA512 512k I2C EEPROM driver
PostPosted: Sat Jun 25, 2005 9:53 am     Reply with quote

This is a nice little header file to drive Microchip's 24xxyyy series of I2C EEPROMS. It works for me, but if there are any problems please let me know and I'll correct whatever is messed up. Very Happy

Code:
#define baseAddress24AA512 0xA0

void writeByte24AA512(int8 deviceAddress, int16 memAddress, int8 data);
int8 readByte24AA512(int8 deviceAddress, int16 memAddress);

void writeByte24AA512(int8 deviceAddress, int16 memAddress, int8 data)
{
   i2c_start();
   i2c_write(baseAddress24AA512 + (deviceAddress<<1));
   i2c_write(memAddress>>8);
   i2c_write(memAddress);
   i2c_write(data);
   i2c_stop();
   delay_ms(5);
}

int8 readByte24AA512(int8 deviceAddress, int16 memAddress)
{
   int8 returnByte=0;
   
   i2c_start();
   i2c_write(baseAddress24AA512 + (deviceAddress<<1));
   i2c_write(memAddress>>8);
   i2c_write(memAddress);
   i2c_start();
   i2c_write((baseAddress24AA512 + (deviceAddress<<1))|1);
   returnByte = i2c_read(0);
   i2c_stop();
   return returnByte;
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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