Page 1 of 1

I2C EEPROM

Posted: Mon Jan 06, 2014 3:41 pm
by stewartbaker
To try and gain some understanding of I2C I have been playing with the EEPROM R/W example.

I have made a few small changes to make it easier for me to understand. However, there is one issue I have yet to get to the bottom of.

When reading then writing to my hardware EEPROM the contents are one location out. i.e the "H", "i" instead of being in locations 0 and 1 seem to be in locations 1 and 2. What am I missing ?

Cheers
Stewart
I2C EEPROM read and write.fcfx
(12.26 KiB) Downloaded 284 times

Re: I2C EEPROM

Posted: Mon Jan 06, 2014 5:18 pm
by Benj
Hi Stewart,

It looks like your doing everything correct to me so not sure why you are getting these results. What value pull up resistors are you using? Also for interest which specific I2C EEPROM device are you using?

Re: I2C EEPROM

Posted: Mon Jan 06, 2014 5:38 pm
by stewartbaker
Hi Benj,
The pull ups are both 1k, and the EEPROM is a 24C08WP. A0 is tied high, the other address pins low.

Looking with a logic analyser the first data read back is a NULL. Whether this is what was stored, or a misread I don't know.

Cheers
Stewart

Re: I2C EEPROM

Posted: Mon Jan 06, 2014 6:00 pm
by Benj
Hi Stewart,

Aha think I have spotted the issue. You are setting the internal address using two bytes but the device only has one address byte according to the datasheet. Therefore sending address LSB of 0 is actually writing 0 to the first EE location.

Re: I2C EEPROM

Posted: Mon Jan 06, 2014 6:04 pm
by stewartbaker
Ah !

That may well be the answer. I will try modified code tomorrow and let you know if that fixes it.

Many thanks

Stewart

Re: I2C EEPROM

Posted: Tue Jan 07, 2014 9:22 am
by stewartbaker
That was the problem.

Many thanks

Stewart