Hi guys.
I'm new to arduino, and am working on a project which will heavily involve using i2c protocals. As such I wanted to work out the basic read/write functions. So I connected it to a 24C65 EEPROM chip, and using an example I found on this forum, tried to write to and then read from the external memory chip. My code is below:
#include <Wire.h>
#define CHIP B1010000
void setup()
{
Wire.begin();
Serial.begin(115200);
Wire.beginTransmission(CHIP);
Wire.send(0); //sets memory pointer to 0
Wire.send(2); // sends value 2 to that location
Wire.endTransmission();
delay(1000);
Wire.beginTransmission(CHIP);
Wire.send(0x02); // moves pointer to memory location 02
Wire.send(2); // sends value two to that location
Wire.endTransmission();
delay(1000);
Wire.beginTransmission(CHIP);
Wire.send(0x03);
Wire.send(2);
Wire.endTransmission();
delay(1000);
Wire.beginTransmission(CHIP);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(CHIP,8);
while(Wire.available())
{
char c = Wire.receive();
Serial.print(c,HEX);
Serial.print(", ");
}
}
Now, I've got some partial success on the read side, in so much as it does read the required amount of bytes, if I ask it to read 8 bytes, I get 8 values in the serial window, if I ask it to read 16 bytes I get 16 values in the serial monitor etc, etc.
The problem I have is that it always reads the same value, -1 (in DEC), despite what else I try to write to those memory locations.
Can anyone help as to what I am doing wrong?
Cheer sfor any help.