Hi Guys, this is a really really old thread I know.... but after several days struggling to get my 24LC256 eeprom working I'm stuck.
Here's the setup .....
Hardware: It's wired with (A0, A1 and A2) to Gnd giving an I2C bus address of 0x50. WP and Vcc are wired to Gnd enabling write operations. SCL and SDA connected to my Mini, and I've used two 4k7 pullups. Both the Mini and the 24LC256 are powered with 5v.
Software: Have tried lots of variants on the same theme, but have now implemented/copied Stefan code above with a variation to return the byte count returned by i2c.Execute(..), and to accept CLockRate and bus timeouts as constructor parameters.
private static void Test24LC256() { OutputPort sda = new OutputPort(Pins.GPIO_PIN_9, Hardware.Helpers.High); Thread.Sleep(200); sda.Write(Hardware.Helpers.Low); sda.Dispose(); const byte ff = 0xff; const int Address = 0x00; const int ClockSpeed = 100; const int TimeoutMilliseconds = 500; byte[] buffer = new[] {ff,ff,ff,ff,ff,ff,ff,ff,ff,ff}; Ic24LC256 storage = new Ic24LC256(false, false, false, ClockSpeed, TimeoutMilliseconds); Debug.Print("Write> " + storage.Write(Address, (new byte[] {0, 46, 125, 0, 0, 224, 183}))); Debug.Print("Read> " + storage.Read(Address, buffer)); }
The output is:
Write> 9
Read> 2
and buffer contains a full set of 0xff's
The Write count of 9 looked good.. until I tried removing the power from the eeprom... and the code returned the same result..!!
The Read count never looked good. The number returned here is the length of the byte buffer used in CreateWriteTransaction used to set the read address. If I make that buffer [n] long, then the Read count shows [n]. In all cases the read buffer is untouched - it contains the same contents it was initialised with, in the code above 0xff's
Suggestions anyone? Stefan... you wouldn't happen to still have your hardware diagram?
Update: Just discovered that I can remove the 24LC256 from my breadboard and the software works identically to when the chip is inserted. Look to me the the Mini isn't talking I2C at all. Very odd.