I have a very big problem by writing a list of strings to an eeprom (24LC1025) Your help with my problem highly appericiated.
I have a data matrix, PageData[111][96] and I want to write all them at once, line by line to the eeprom. I am using arduino for coding.
the code is :
{
#include <Wire.h>
#define EEPROM_ADDR 0xA0;
void setup()
{
Wire.begin();
Serial.begin(9600);
int PageData[111][96]={ my data is here ... }
for (t=0; t<111; t++){
for (unsigned long i=0; i<96; i++){
m=i*2;
value[m] = highByte(PageData[t][i]);
value[m+1] = lowByte(PageData[t][i]); }
at=((t*192));
for (unsigned long i=0; i< 192; i++) {
i2c_eeprom_write_byte(EEPROM_ADDR,(at+i),value[i]);
delay(5); }
}
void i2c_eeprom_write_byte( int deviceaddress, unsigned long eeaddress, byte data )
{
if( eeaddress > 65535 )
deviceaddress = deviceaddress | B00001000;
deviceaddress = deviceaddress >> 1;
byte rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // Address High Byte
Wire.write((int)(eeaddress & 0xFF)); // Address Low Byte
Wire.write(rdata);
Wire.endTransmission();
}
My problem in this code: when I want to read the eeprom for the checking the strings, I realize, it does not write the eeprom the whole 111 line. It just writes randomly sometimes half of this sometimes less than this amount.
I tried several ways to solve the problem. but now I am desperate , please check this and tell me where i miss a point. Please let me know, if any information you need for the answer.