I2C EEPROM trouble

Hello,
I try to use a ATMLU940 2FB 2.
First did I find it's I2C address by using the arduino sketch "i2c_scanner". It did found 0x20 (well, the i2c lcd) and 0x7C. The only problem: there was no other device then the lcd.

A day ago was there a i2c eeprom and I have used the address 0x7C. I did read it (each address was described with 87) but I wasn't able to write something.

Therefore did I test the behavior of the i2c eeprom. What I found was surprising:

I did remove the part - but the i2c scanner did find the 0x20 and the ox7C like bevore.

Then did I read the not existing i2c eeprom at the adress 0x7C: the same result as I get with the i2c eeprom. Additionally did I change the i2c address from 0x7c to other addresses (0x6D ....). And there was the same result. Finally I read until eeprom address 80000 (the i2c chip has only may be 10k) - no problem, the result was 87 in each cell.

Is there a expert who can me help?
What do I read and how can I install the device correctly?

Thank in advance!
mgbd

Please post a link to the chips datasheet and post the code you're using to access it. Please also post a diagram of the wiring from the chip to the Arduino and the type of Arduino you're using.

hi pylon,
the link to the eeprom is difficultly to find out because the devices name and the text on the device is different:

http://www.atmel.com/dyn/resources/prod_documents/…:

The wiring is “normally” I think without failure: Vcc, Gnd, sda, scl, wp (at gnd), 3 address-pins.(difficult to post a picture).

Here is the code:

//  _2_Werte_ausl_I2C_EEPROM                                   5.2.17

// aus dem I2C-EEPROM zwei Zahlenwerte, die aus je zwei
// Bytes bestehen, auslesen.
// Seriell ausdrucken: EEPROMadresse, die einzelnen Bytes und die 
// daraus zusammengesetzten Zahlenwerte. 



#include<Wire.h>
//#include<EEPROM.h>            // nur für internes EEPROM benötigt
const int I2CADRESSE = 0x7C;
int eepromadresse;
int Value_a, Value_b;
byte value1, value2, value3, value4;

void setup() {
int Wert;
   Wire.begin();
   Serial.begin(9600);
int eepromadresse = 0;


  Wert = 1234;

 for (eepromadresse = 0; eepromadresse < 1000; eepromadresse++){
  schreibEEPROM(eepromadresse, highByte(Wert));
  eepromadresse++;
  schreibEEPROM(eepromadresse, lowByte(Wert));
   }
 

 for (eepromadresse = 0;  eepromadresse < 80000; eepromadresse++){
  value1 = (liesEEPROM(eepromadresse));
  eepromadresse++;
  value2 = (liesEEPROM(eepromadresse));
  eepromadresse++;
  value3 = (liesEEPROM(eepromadresse));
  eepromadresse++;  
  value4 = (liesEEPROM(eepromadresse));
  

  Serial.print(eepromadresse);
  Serial.print("\t");
  Serial.print(value1);
  Serial.print("\t");
  Serial.print(value2);
  Value_a = value1 << 8 | value2;
  Serial.print("\t");
  Serial.print(Value_a, DEC);
  Value_b = value3 << 8 | value4;
  Serial.print("\t");
  Serial.println(Value_b, DEC);
  
  }
}  
 

void loop()
 {};

//  Unterprogramme

  byte liesEEPROM( unsigned int eepromaddress)   // byte datenbyte=0xFF)
{
  byte  datenbyte;                           // = 0x00;
  Wire.beginTransmission(I2CADRESSE);
  Wire.write ((byte) (eepromaddress >> 8));
  Wire.write ( (byte) (eepromaddress & 0xFF));
  Wire.endTransmission();
  Wire.requestFrom(I2CADRESSE, 1);         //  1 ... heißt ein Byte ,1???
  if (Wire.available())
    datenbyte = Wire.read();
  return datenbyte;
}

void   schreibEEPROM(int adresse, byte daten) 
  {  
  Wire.beginTransmission(I2CADRESSE);
  Wire.write ((byte) (adresse >> 8));
  Wire.write ( (byte) (adresse & 0xFF));
  Wire.write (daten);
  Wire.endTransmission();  
  delay(5);
  }

forgotten:

PS The arduino I use is a Leonardo, the IDE is 1.8.1

The chip is AT24C512B - http://www.atmel.com/Images/doc5297.pdf
(ATMLU = PDIP package, 940 = date code - details of marking scheme on page 13)

The (7-bit) address is 0b1010xxx (0x50-0x57) (page 10).

I did hope, the program "I2C_scanner" would say what the i2c address is, but it seems not to be so.

The scanner found the correct lcd address (0x20) but for the eeprom device it write 0x7C - even if it is not connected.
The changed i2c eeprom (A0 = +, A1 and A2 = gnd should be 0x51) is not found by i2c_scanner but also not by the code.

But independent from that problem, why did my code shows some results from not working eeproms?

But independent from that problem, why did my code shows some results from not working eeproms?

  byte liesEEPROM( unsigned int eepromaddress)   // byte datenbyte=0xFF)
{
  byte  datenbyte;  // = 0x00;
  Wire.beginTransmission(I2CADRESSE);
  Wire.write ((byte) (eepromaddress >> 8));
  Wire.write ( (byte) (eepromaddress & 0xFF));
  Wire.endTransmission();
  Wire.requestFrom(I2CADRESSE, 1);         //  1 ... heißt ein Byte ,1???
  if (Wire.available())
    datenbyte = Wire.read();
  return datenbyte;
}

You commented out the explicit initialization for datenbyte. Why did you do that?

Your read function will return whatever preexisting value is in the datenbyte memory location, whether it takes a value from Wire.read() or not.

You commented out the explicit initialization for datenbyte. Why did you do that?

I did think it is of no importance because the value is definded later correctly.

Your read function will return whatever preexisting value is in the datenbyte memory >location, whether it takes a value from Wire.read() or not.

Yes I see. I have to insert something to detect a failure if there is nothing to read. May be if it reads the zero (zero is no valid value of measuring.

It remains the problem of detecting the i2c eeprom address. The i2c-scanner doesn't work and even not the method of oqibidipo (0b1010xxx)

I did think it is of no importance because the value is definded later correctly.

No, it isn't.

The wiring is "normally" I think without failure: Vcc, Gnd, sda, scl, wp (at gnd), 3 address-pins.(difficult to post a picture).

That are the pins of the EEPROM chip. Where did you connect them on the Leonardo? Do you have external pullups or do you just rely on the internal ones of the ATmega32U4?
Did you left the 3 address pins floating? Did you connect them to GND? To Vcc? There is no "normal" wiring. It may be correct or wrong but there are several wiring methods that are correct, depending on the rest of the system you have.

In your code you don't check the return values of the Wire methods (p.e. endTransmission() and requestFrom()), so you don't know if the device answered on the I2C bus.