I am using blenano with mbed compiler and a 24LC256 eeprom.
the output o screen I get is the no. of total chars, i.e, 65355. below is the code.
#include "mbed.h"
#include "ble/BLE.h"
#include "SoftI2C.h"
int test =1000;
lcd.clear();
lcd.setPosition(0, 0);
lcd.printf("Writing bytes 0-16\n");
wait(0.2);
char data[4];
data[0] = 0; // MSB address
data[1] = 255; // LSB address
data[2] = test; // data
data[3] = test>>8;
if(i2c.write(0xA0, data, 4)) {
lcd.clear();
lcd.setPosition(0, 0);
lcd.printf("Write failed\n");
}
while(i2c.write(0xA0, NULL, 0));
lcd.clear();
lcd.setPosition(0, 0);
lcd.printf("Setting read pointer to 0\n");
wait(0.2);
lcd.clear();
lcd.setPosition(0, 0);
lcd.printf("Reading back data bytes 0-16\n");
wait(0.2);
char response[2];
for(int i=0; i<256; i++) {
if(i2c.read(0xA0+0x01, response, 2)) {
error("Read failed\n");
}
lcd.clear();
lcd.setPosition(0, 0);
lcd.printf("address %d", (response[0]<<8)|response[1]);