- #1
trustnoone
- 17
- 0
hi guys, so I'm trying to save data onto my EEPROM, the problem is it works for a while of data, but not all of it. I'm not sure if its a problem with reading though, or the writing part. Essentially I'm writing an integer value into the EEPROM to obtain later, although I expect to have quite a few pieces of data in there.
I'm using the 24LC256 EEPROM
Currently my writing to EEPROM is as follows:
<Altered as its quite long>
I think a big problem I am having is I don't quite understand it too well either, so its pretty much just a combination of a few examples I've found online.
It should write to the EEPROM once per minute (although its a little longer due to the 4ms delay), over like 8 hours, preferably more, but just testing 8 hours for now. The problem is when I read from my EEPROM I only obtain about 2 hours, and then it just go's back over everything again.
If you feel it might be better for me to post my read code I will be happy to do that as well.
Thanks heaps for any help.
I'm using the 24LC256 EEPROM
Currently my writing to EEPROM is as follows:
<Altered as its quite long>
Code:
int address = 0;
#define disk1 0x50 //Address of 24LC256 eeprom chip
..
..
loop{
//obtain time value here
eepromWriteInt(disk1, address, timeTemp.toInt()); //timetemp is just an integer time value
address+=2;
delay(60000);
}
void eepromWriteInt(int theDeviceAddress, unsigned int theMemoryAddress, int theInt)
{
byte theByteArray[sizeof(int)] = {
(byte)(theInt >> 8), (byte)(theInt >> 0)};
eepromWrite(theDeviceAddress, theMemoryAddress, sizeof(int), theByteArray);
eepromAddress=eepromAddress+2;
}
void eepromWrite(int theDeviceAddress, unsigned int theMemoryAddress, int theByteCount, byte* theByteArray)
{
for (int theByteIndex = 0; theByteIndex < theByteCount; theByteIndex++)
{
Wire.beginTransmission(theDeviceAddress);
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 8));
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 0));
Wire.write(theByteArray[theByteIndex]);
Wire.endTransmission();
delay(4);
}
}
I think a big problem I am having is I don't quite understand it too well either, so its pretty much just a combination of a few examples I've found online.
It should write to the EEPROM once per minute (although its a little longer due to the 4ms delay), over like 8 hours, preferably more, but just testing 8 hours for now. The problem is when I read from my EEPROM I only obtain about 2 hours, and then it just go's back over everything again.
If you feel it might be better for me to post my read code I will be happy to do that as well.
Thanks heaps for any help.