MrAl:
Hello there,
Anyone know the single byte write time for this EEPROM or similar?
This is at 5v, and the data sheet says 10ms max but i'm seeing more like 0.5ms but not sure if that is right or not yet. That includes the time to call the Wire library for I2c.
It is spec'd to happen within 10ms, The actual time is device, data dependent. Are you asking for a guaranteed exact write time? If so, there is no answer. The EEPROM is erased by injected electrons into a floating 'well'. The electron tunneling is not deterministic. It depends on the thickness of the insulating layer, the number of electrons currently inhabiting the 'well', the voltage generated by the chip's high voltage charge pump.
Each memory cell of the chip may be different. So, they only spec the worst case duration.
You do understand that this device has a 32 byte write page size? This means that any time you write to the device, 32 bytes are actually erased, written. And you have to take care when writing multiple bytes that all of the bytes you send fit on one 32 byte page?
This means that the chip is organized in multiple 32 byte pages:
page address Range
0 0..31
1 32..63
2 64..95
If you use code like this to write a multibyte buffer to the EEPROM:
void writeBlock(uint8_t i2cAddress, uint16_t addr, char *ch, uint8_t len){
Wire.beginTransmission(i2cAddress);
Wire.write(highByte(addr));
Wire.write(lowByte(addr));
Wire.write(ch,len);
Wire.endTransmission();
}
It will not correctly store the data if (((addr+len)/32) != (addr/32)). This is because of the 32 byte write buffer.
The way I2C EEPROMS store data is something like this.
The Chip receives the Write command, it decodes the address, finding which of the 32Byte pages you will be changing.
Then it fills the page write buffer with the current contents of it's EEPROM page.
Then it starts overwriting the page write buffer with the data coming in the I2C buss. It has a 5bit index register (0..31) that indicates where in the buffer the next byte is to be stored. After each byte is received from the I2C buss, this index pointer is incremented. If it is incremented past 31, it starts over at 0. So, this mean that if your multibyte buffer is 10bytes long and you want it stored starting at address 25, your first 7 bytes are stored at addresses[25..31], and the remaining 3 bytes are stored at addresses [0..2].
After the I2C write instruction has completed, the Chip Erases the current page, then writes the data from the page write buffer into the newly erased memory cells.
So, if you are going to write multiple bytes in one I2C transaction, you must consider the page size of the EEPROM you are using. The write page size is device dependent. Some of the little 2k EEPROMs have as small as a 4byte page size, some of the larger ones have 256 byte buffers.
Chuck.