Go Down

Topic: Problem for reading and writting I2C Eeprom 24c02 6 (Read 6 times) previous topic - next topic

hary

#5
Feb 12, 2013, 01:45 pm Last Edit: Feb 12, 2013, 02:50 pm by hary Reason: 1
Hello Nick

It gives :

I2C scanner. Scanning ...
Found address: 80 (0x50)
Done.
Found 1 device(s).


I've test another one in SOIC package and I get :
I2C scanner. Scanning ...
Found address: 80 (0x50)
Found address: 81 (0x51)
Done.
Found 2 device(s).


But when I try to write and read, there is only 255 in each Byte.






el_supremo

In the readData function try this instead of endTransmission():
Code: [Select]
  Wire.endTransmission(1);

Pete

hary

#7
Feb 12, 2013, 04:44 pm Last Edit: Feb 12, 2013, 04:47 pm by hary Reason: 1
Unfortunately, no change El Supreremo!


still 255 all the time !

PaulS

Code: [Select]
  Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));

After going to the trouble of splitting the int address into low order byte and high order byte, why are you then casting the bytes to ints?

el_supremo

The 24c02 only has 256 bytes. It only uses one byte of addressing so you would have to address it like this:
Code: [Select]

  Wire.beginTransmission(i2caddr);
  // set the pointer position
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission();

I don't know if it needs the repeated start bit. If the above doesn't work, try it with Wire.endTransmission(1)

Pete

Go Up