I2C and EEPROM

Hi,

I'm trying to get the eeprom (24LC08) running on the Embedded Artist LPCExpresso Base board. All is fine apart from getting the acknowledge back from the i2c.write() call following an eeprom write (you are supposed to poll the ack bit to know when the write is complete). The write has gone throught ok as I can see the change from an eeprom read().

Now I see the ack bit on the scope changing correctly but I only ever get a 0 back from the write() call.

Anyone any experience on this?

15 Jul 2010

Would it be possible for you to post the section of code that is causing trouble?

Jon,

My write byte to eeprom code, it hangs in the while(!ack) still even after many experiments and viewing the ack bit on the scope where I see the ack bit being cleared on the bus.

Thanks for your interest

Tim

void ee_write_byte( int addr, char data )
{
int ack;

i2c.start();          //send start on bus
i2c.write( 0xa0);     //write command to bank 0
i2c.write( addr );    //write address
i2c.write( data );    //write data
i2c.stop();           //send stop on bus

ack = 0;
i = 40;
while( !ack )         //wait for ack
{
i2c.start();              
ack = i2c.write( 0xa0 );    //write command to set ack
}

}

16 Jul 2010

I've just managed to recreate this on my desk with an 24LC256, and can confirm it is a bug. I will investigate.

Until it is fixed, you could use a short wait(), instead of a poll - I noticed that the '256 device was acking my first request.

Thanks Jon, good to know I have not finally cracked then!

26 Aug 2010

There is a version 25 available which should fix this.