I hit an issue I was not able to figure it out. So basically everything seems to work. But when I write one block (16 bytes) and when I read the full memory I found the same block to repeat at every 4096 bytes. All my blocks are aligned at 16 byte offset, so I'm not crossing pages.
Before I do the test I go over the whole memory and zero it. Full read validates that the memory is empty. Than single write and again full read shows the same block on multiple places. So I guess it is somehow related to the addressing, but the MSB/LSB stuff seems correct.
So if I write data to address 128 (block 8) the data doesn't appear only there, but appears on all of the following addresses:
128
4224
8320
12416
16512
20608
24704
28800
Here are the functions. I use them only for aligned 16 byte blocks, so I read/write a few bytes at a time instead of writting one by one with delay.
void validateOperation(...) -> checks if expected data is read/written and the result of the endTransmission is = 0
void EepromRead(unsigned int address, byte* data, int dataSize) {
Wire.beginTransmission(AT24Cxx_CTRL_ID);
Wire.write((int)(address >> 8));
Wire.write((int)(address & 255));
int res = Wire.endTransmission();
if (res != 0) {
validateOperation(0, 0, res, address);
return;
}
delay(50);
Wire.requestFrom(AT24Cxx_CTRL_ID, dataSize);
int bytes = Wire.readBytes(data, dataSize);
validateOperation(bytes, dataSize, 0, address);
}
void EepromWrite(unsigned int address, byte* data, int dataSize) {
Wire.beginTransmission(AT24Cxx_CTRL_ID);
Wire.write((int)(address >> 8));
Wire.write((int)(address & 255));
int val = Wire.write(data, dataSize);
int res = Wire.endTransmission();
validateOperation(val, dataSize, res, address);
delay(50);
}
The delay is pretty big, but even smaller one (delay(5)) doesn't make difference at all. All read/writes are successful. So I need hints...
The memory is marked with ATHGV131 / 24C32BN / SU27.