Eeeprom and I2C access

20 Aug 2012

Hello everybody !

I tried to configure an access to an eeprom witch use I2C bus interface. ST M24LR16E, datasheet http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00031737.pdf

I have read it five times, but I need glasses : I don't where are the technical informaion for I2C access, especially adress of the slave, memory use adress for use directly mbed library.

I think : Slave adress 1010 = 0x0A 1 Kbit EEPROM sector = 0x00

The device is delivered with all bits in the user memory array set to 1 so I have written the follow code, and connected the pull-up resistor on my I2C mbed pins connection. But nothing happen. The code stay on the line ??

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);

int main() {
        I2C i2c(p9, p10);       
        pc.printf("Starting....")
        wait(1);
        int add = 0x0A;
    
        char Tab[1];

        i2c.start();
        int statuw = i2c.read(add, Tab, 1, true);
        i2c.stop(); 
       pc.printf("Done !");

        int rep = Tab[0];
        pc.printf("Value : %F \n\r",  rep);


}

Thanks for your help!

GM

21 Aug 2012

these eeproms are normally 0xA0 the LSBits could be A0,A1,A2 with the LSBit being R/W. So address 0xA0 for write and 0xA1 for read.

21 Aug 2012

Thank you for the reply !

I read this morning the datasheet. And in the table 2, device adress to read is 0b10101111=0xAF and 0b10101110 = 0xAE to write. Isnt't it ?

I looking for a 0 ack statut byte for a simple write operation through i2c. so i tried the following :

      I2C i2c(p28, p27);       
        pc.printf("Started... ");
                 
        for (int cc = 0x00 ; cc <= 0xFF; cc++){
            for (int add=0x0000; add <=0xFFFF; add++) {   
            
                const char crc[1]={cc};
    
            i2c.start();
            int stb1 = i2c.write(add, crc, 2, true);
            i2c.stop();
            pc.printf(".");
            
            if (stb1==0){
           
            pc.printf("Statut for %X and %X: %X \n\r",  add, cc, stb1);
}
            }
        }

But with not fine results !

22 Aug 2012

Sorry for the delay! I have had a look at the datasheet now. It would suggest to me that a generic 24xx16 eeprom lib should work, see here for one http://mbed.org/users/bborredon/code/eeprom/wiki/Homepage Three out of the four LSBits are used for passwords, so may i suggest that you get a simple program working first, then you can go forward and write the rest of your lib when you have a better understanding of the device. If you need help with using BBorrendon's code I can probably help further.