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

External EEPROM (24LC256) interface WITH 12F675

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







External EEPROM (24LC256) interface WITH 12F675
PostPosted: Thu Apr 10, 2003 10:15 pm     Reply with quote

Hi All

I am trying to interface an external EEPROM(microchip's 24LC256) with 12F675 and using PCW ver3.14,PCM ver 3.091. unfortunately i am not able to read or write to the external memory. I would greatly appreciate any help or pointers.

thanks
swamy


parts of the code i used are as follows,

#use i2c(master,sda=PIN_A1,scl=PIN_A2,slow)

void write_eeprom_now(u16 address, u16 value)
{
u8 lbyte;
u8 hbyte;
u8 albyte;
u8 ahbyte;

lbyte = value;
hbyte = (value >> 8);

albyte = address;
ahbyte = address >> 8 ;

i2c_start();
i2c_write(0xa0);
i2c_write(ahbyte);
i2c_write(albyte);
i2c_write(lbyte);
i2c_write(hbyte);
i2c_stop();
// check if write is done by EEPROM
do { i2c_start(); }
while(i2c_write(0xa0));
i2c_stop();
}

u16 read_eeprom_now(u16 address)
{
u8 lbyte = 0;
u8 hbyte = 0;
u8 albyte;
u8 ahbyte;

albyte = address;
ahbyte = address >> 8;

i2c_start();
i2c_write(0xa0);
i2c_write(ahbyte);
i2c_write(albyte);
i2c_start();
i2c_write(0xa1);
lbyte=i2c_read(1);
hbyte=i2c_read(0);
i2c_stop();

return( (u16)hbyte << 8 + lbyte);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 13597
Pete Smith
Guest







Re: External EEPROM (24LC256) interface WITH 12F675
PostPosted: Fri Apr 11, 2003 1:17 am     Reply with quote

:=Hi All
:=
:=I am trying to interface an external EEPROM(microchip's 24LC256) with 12F675 and using PCW ver3.14,PCM ver 3.091. unfortunately i am not able to read or write to the external memory. I would greatly appreciate any help or pointers.

First thing to do is check to see if you've got pullup resistors on the SDA and SCL lines. Something around 2.2k should do. Without these, nothing will happen!

Also, check that WP is left floating or pulled to Vss/Vcc.
Also, you're using 0xA0 as the main device address. Make sure A0,A1 and A2 on the 24L256 are pulled low.

I can't see anything wrong with your code, quickly scanning it.

HTH

Pete.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13599
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: External EEPROM (24LC256) interface WITH 12F675
PostPosted: Fri Apr 11, 2003 11:36 am     Reply with quote

:=Hi All
:=
:=I am trying to interface an external EEPROM(microchip's 24LC256) with 12F675 and using PCW ver3.14,PCM ver 3.091. unfortunately i am not able to read or write to the external memory. I would greatly appreciate any help or pointers.
:=
------------------------------------------------------------
Do everything Pete says, but you should also look at this post:
<a href="http://www.pic-c.com/forum/general/posts/10971.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/10971.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13619
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