EEPROM problem

08 Sep 2009

Hi,

I want to read data from EEPROM specified address ,and use I2C read function.

It's parameters has only a general address ,has not subaddress.

EEPROM address is 0xA0,and subaddress is from 0x00 to 0x39.

Please tell me how to do !

Thanks

zhenjiang

08 Sep 2009

Hi Zhenjiang,

I want to read data from EEPROM specified address ,and use I2C read function.

It's parameters has only a general address ,has not subaddress.

EEPROM address is 0xA0,and subaddress is from 0x00 to 0x39.

Please tell me how to do !

Whilst most datasheets manage to avoid giving examples, but they should give you all the information you need to operate the device.

Have a go at working through these:

  • Have you got a part number for the EEPROM and an associated datasheet? What is it?

If the EEPROM is part of a module, it may be the datasheet for the module only has a summary. Try looking up the datasheet for the EEPROM part used.

  • What have you tried? Post or publish the test program you are testing the EEPROM with, and someone may spot a problem.

As a posting style guideline, it is probably best to keep related questions and discussions under the same topic. The thread you started yesterday (http://mbed.org/forum/topic/106/) would have been fine to continue the questioning. Starting lots of threads about the same topic or repeating the question will tend to clog up a forum and might upset some people.

Please post your results! (to this thread!)

Thanks,

Simon

08 Sep 2009 . Edited: 08 Sep 2009

Hi Simon,

My EEPROM is '24C02' , address is 0xA0.

I want to read data from subaddress.  RANDOM ADDRESS READ

I do not know the sub-address in the parameters of read function.

read(int address ,char *data ,int length);

The parameters of this function is not defined sub address.

I don't know how to do.

So I can only use the loop,

This is my code:

#include "mbed.h"

I2C i2c(p28, p27);
Serial pc(USBTX, USBRX);
DigitalOut myled1(LED1);

char read_data[1];
const int eeprom_addr=0xA0;  // EEPROM address

int main() {

    pc.printf("Program Begin ...\n");
    myled1=0;

    for(int i=0;i<58;i++){
       char read_data[1];
       int a=i2c.read(0xA0,read_data,1);
       pc.printf("%x - ",read_data[0]);
       wait(0.5);
    }
    wait(1);
    myled1=1;

}

This is printf result:

Program Begin ...
ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff - ff -

Thanks!

zhenjiang

08 Sep 2009

Hi zhenjiang,

I've just done some quick tests with a 24LC256, which I assume is a very similar part. You can see this at:

http://mbed.org/projects/cookbook/wiki/24LC256

Looking at your example, it may be that you need to set the read pointer (it may be random at power on) before reading. Look at the example test program I end up with for a hint at how to do that.

Hope this helps,

Simon

08 Sep 2009
Hi Simon,
Thanks for your help, I can read data from the EEPROM subaddress now. I am very glad !
Thanks
zhenjiang