Writing to eeprom gives no ack

15 Dec 2011

Hi, I want to acces a 24LC1025 from Microchip. Whenever I write something to the device, I got no ACKs. I have testet this with two other eeproms without success. The SDA and SCL are pulled high to 5V via 10k (also tested with 1k and 3k3)

Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21941J.pdf

Here is the code and the result. Maybe someone has a suggestion:

   I2C cmp(p28, p27);				// I2C sda,scl

    printf(" I2C Reset!\n");
    cmp.frequency(400000);
    int ret;
    char buf[128];

    cmp.start();				// Start condition
    ret= cmp.write(0xA0);
    printf(" 1:%i\n", ret);
    ret= cmp.write(0x00);
    printf(" 1:%i\n", ret);
    ret= cmp.write(0x00);
    printf(" 1:%i\n", ret);
    for (i=0; i<5; i++)
        printf(" write:%i  %i\n", i, cmp.write(i));
    cmp.stop();				// Stop condition
    wait_ms(30); //write cycle time for page update


    cmp.start();				// Start condition
    ret= cmp.write(0xA0);
    printf(" 2:%i\n", ret);
    ret= cmp.write(0x00);
    printf(" 2:%i\n", ret);
    ret= cmp.write(0x00);
    printf(" 2:%i\n", ret);
    cmp.start();				// Start condition
    printf(" 2:%i\n", cmp.write(0xA1));
    for (i=0; i<5-1; i++) {
        buf[i]=cmp.read(1); //ACK
        printf(" read:%i  %i\n", i,buf[i] );
    }
    i++;
    buf[i]=cmp.read(0); // NOACK
    printf(" read:%i  %i\n", i,buf[i] );

    cmp.stop();				// Stop condition

Result:

 I2C Reset!
 1:0
 1:0
 1:0
 write:0  0
 write:1  0
 write:2  0
 write:3  0
 write:4  0
 2:0
 2:0
 2:0
 2:0
 read:0  255
 read:1  255
 read:2  255
 read:3  255
 read:5  255
16 Dec 2011

How are A0, A1, A2 wired? A2 must be tied high and based on your code, A0 & A1 need to be tied to ground.

I would also use 2K resistors to pull up SDA and SCL. Probably not the issue but when having problems it helps to hold to the part's spec. 100%

16 Dec 2011

As you mentioned, A0 and A1 are GND and A2 is VCC. I will try with 2k resistors to be safe. I also tested variable speeds (100, 400, 600, 1000kHz)

16 Dec 2011

That pretty much eliminates any hardware issues. If you have a logic analyzer, I would check the timing and clock/data phasing.

16 Dec 2011

Hmm, there should be at least a _single_ ACK. I suspect something with the wiring going wrong (swapped lines?). Looking with logic probe would help (if you set a really low bus speed, you might even use a low-current LED connected to SDA / SCL).

And did you test the EEPROM with 3.3 volts?

16 Dec 2011

I tried both, 5V and 3V3.

17 Dec 2011

Now it works :-) I have re-wired all connections and put 2k resistors on it. The ACK is sent now and the results are as expected:

 I2C Reset!
 1:1
 1:1
 1:1
 write:0  1
 write:1  1
 write:2  1
 write:3  1
 write:4  1
 2:1
 2:1
 2:1
 2:1
 read:0  0
 read:1  1
 read:2  2
 read:3  3
 read:5  4

Many thank for the help!!