|
|
View previous topic :: View next topic |
Author |
Message |
swamy Guest
|
External EEPROM (24LC256) interface WITH 12F675 |
Posted: Thu Apr 10, 2003 10:15 pm |
|
|
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 |
Posted: Fri Apr 11, 2003 1:17 am |
|
|
:=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
|
Re: External EEPROM (24LC256) interface WITH 12F675 |
Posted: Fri Apr 11, 2003 11:36 am |
|
|
:=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 |
|
|
|
|
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
|