I am trying to read an EEPROM (a Microchip 24LC00 EEPROM (see datasheet)) using an Arduino Diecimila and the Wire library. Here is my code:
/*
The function of this sketch is simply (ha!) to read a Microchip 24LC00 EEPROM
and write the output to the serial port.
*/
#include <Wire.h>
#define CG 0x50 // The address of the chip
void setup()
{
Serial.begin(115200); // Initialize our serial port
Wire.begin(); // Join the I2C bus as master (no addres req'd)
manualIncrementRead(0, 32);
autoIncrementRead(0, 32);
}
void manualIncrementRead (int startAddress, int length )
{
Serial.println("\n\n** Starting Manually Incremented Read Operation **\n");
int c;
int currentAddress = 0;
for (c=0; c < length; c++)
{
currentAddress = startAddress + c;
movePointerTo(currentAddress);
Wire.requestFrom(CG, 1);
Serial.print(Wire.receive(), DEC);
Serial.print("\t");
}
Serial.println("\n\n** Manually Incremented Read Operation Complete **\n\n");
}
void autoIncrementRead(int startAddress, int length)
{
Serial.println("\n\n** Starting Automatically Incremented Read Operation **\n");
int c;
int currentAddress = 0;
movePointerTo(currentAddress);
Wire.requestFrom(CG, length);
while (Wire.available())
{
Serial.print(Wire.receive(), DEC);
Serial.print("\t");
}
Serial.println("\n\n** Automatically Incremented Read Operation Complete **\n\n");
}
void movePointerTo (int address)
{
Wire.beginTransmission(CG);
Wire.send(address);
Wire.endTransmission();
}
void loop()
{
// do nothing
}
And here are the results. One key that I find interesting is that I get the exact same result sets with the EEPROM completely disconnected. Obviously, I am erring in my code somewhere, but I have no idea where.
** Starting Manually Incremented Read Operation **
0 1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26
27 28 29 30 31
** Manually Incremented Read Operation Complete **
** Starting Automatically Incremented Read Operation **
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0
** Automatically Incremented Read Operation Complete **
Thanks for any and all comments.