Arduino Forum

Forum 2005-2010 (read only) => Hardware => Interfacing => Topic started by: smogmaster on Oct 14, 2009, 11:44 pm

Title: EEprom understanding
Post by: smogmaster on Oct 14, 2009, 11:44 pm
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 ?

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;
Title: Re: EEprom understanding
Post by: Spinlock on Oct 15, 2009, 12:22 am
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:

Modify that to store to your external EEPROM, and you should be fine...
Title: Re: EEprom understanding
Post by: Grumpy_Mike on Oct 15, 2009, 11:11 am
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.  ;)