I'm using AT24C32 EEPROM chip from ATmel. I found code that will write and read bytes from chip. Code writes and reads bytes correctly and without any problem.
But I have to write few 8-byte values often(every 10-15 seconds). I did "cut" those variables to 48 bit(so 6-byte variable) and with that I speeded up saving but it's still slow.
Is there any chance to speed up saving proccess? Code is below
void EEPROMClass::write48(int16_t address, uint64_t value)
{
uint8_t byteValue = (value & 0xFF);
write8(address, byteValue);
byteValue = ((value >> 8) & 0xFF);
write8(address + 1, byteValue);
byteValue = ((value >> 16) & 0xFF);
write8(address + 2, byteValue);
byteValue = ((value >> 24) & 0xFF);
write8(address + 3, byteValue);
byteValue = ((value >> 32) & 0xFF);
write8(address + 4, byteValue);
byteValue = ((value >> 40) & 0xFF);
write8(address + 5, byteValue);
}
void EEPROMClass::write8(int16_t const address, uint8_t const value)
{
Wire.beginTransmission(AT24C32);
Wire.write(highAddressByte(address));
Wire.write(lowAddressByte(address));
Wire.write(value);
delay(2);
Wire.endTransmission();
}
delay
of 2ms is required otherwise EEPROM will write different value. Code has 4 "6-byte" variables(total of 24 bytes). Every byte is minimum 2ms, so total time to save only "6-byte" variables is 48ms(round to 50ms). That is too slow for me. How to speed up write
function?