attachments are my codes and example card dump, hope some one can help me with this.
Many people, including me, will not download a .zip file.
Post the code inline, or attach your code as a .ino
If your data breaks nicely into 16 byte chunks, then that page boundary issue is easy to manage. Just write the chunk and increment the address by 16 each time. The important part is to not do a block write across a page boundary.
Here's an example program showing the 16 byte block writes.
//possible page boundary issue unless all writes at 16 bytes
#include <Wire.h>
#define ADDRESS 0x50 //Address of EEPROM
unsigned int memAddress = 0;//starting eeprom address
int totalBytes = 720;//total byte number multiple of 16
const byte blockLength = 16; //will avoid page boundary in eeprom
const byte numberOfBlocks = totalBytes/blockLength;
//test data visually to confirm pattern
byte fileData[][blockLength] =
{
{0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0,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, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0},
};
void setup() {
Serial.begin(115200);
Wire.begin();
for (int i = 0; i <= numberOfBlocks - 1; i++)
{
writeBytes( ADDRESS, memAddress, fileData[i], blockLength);
memAddress += blockLength;
}
memAddress = 0;//reset address for read
for (int i = 0; i <= numberOfBlocks - 1; i++)
{
readBytes(ADDRESS, memAddress, blockLength);
memAddress += blockLength;
}
}
void loop() {}
void writeBytes(int device, unsigned int Address, byte* data, byte len)
{
Wire.beginTransmission(device);
Wire.write(Address >> 8 ); //MSB
Wire.write(Address & 0xFF); // LSB
Wire.write(data, len);
Wire.endTransmission();
delay(5);//small delay for eeprom to save data
}
void readBytes(int device, unsigned int Address, byte len )
{
byte readBuffer[len];
Wire.beginTransmission(device); // I2C address
Wire.write(Address >> 8); // bit shift for high byte of pointer address
Wire.write(Address & 0xFF); // mask for the low byte
Wire.endTransmission();
Wire.requestFrom(device, len);
Wire.readBytes(readBuffer, len);
for (byte j = 0; j < 16; j++)
{
Serial.print(readBuffer[j], HEX);
Serial.print(" ");
}
Serial.println();
}