Go Down

Topic: EEprom understanding (Read 1 time) previous topic - next topic

smogmaster

Hello Arduino,

I have some simple questions about EEProm's. I use them in my arduino to save some parameters. I also use some i2c eeproms. And i wonder why i can only store values from 0-255 ?

Example:
I2c EEprom - 24c04a
Atmega168 inside eeprom

Is there a way to store some full int values like the unix ticks 1255556437 ?

So maybe you can give me a hint ?

Function to write a value into an 24c04a EEprom:
Code: [Select]

void i2c_eeprom_write_byte( int deviceaddress, int eeaddress, byte data ) {
 int rdata = data;
 Wire.beginTransmission(deviceaddress);
   Wire.send(eeaddress);
   Wire.send(rdata);
   Wire.endTransmission();
}

Spinlock

EEPROM's generally only store 8 bit blocks, or values in each cell from 0 - 255.  

Halley had a good solution in this forum to use templates to store multiple things to EEPROM:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234477290/3#3

Modify that to store to your external EEPROM, and you should be fine...

Grumpy_Mike

#2
Oct 15, 2009, 11:11 am Last Edit: Oct 15, 2009, 11:11 am by Grumpy_Mike Reason: 1
All computer memory nowadays is addressed in bytes (8 bits). Even the ram and flash inside the arduino is addressed in bytes they are the fundamental building block of computers. If you want to store bit patterns that can represent numbers larger than 255 you have to use more than one byte to do this.

Cissy high level languages like C do this for you, but real men know this is just an illusion.  ;)

Go Up