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
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