Puede leer / escribir valores en direcciones de eeprom específicas usando el siguiente código:
(Utilizo macros, pero puede usar las funciones que figuran en eeprom.h directamente si lo prefiere)
#include <avr/eeprom.h>
// macro for eeprom access
#define read_eeprom_byte(address) eeprom_read_byte ((const uint8_t*)address)
#define write_eeprom_byte(address,value) eeprom_write_byte ((uint8_t*)address,(uint8_t)value)
#define read_eeprom_word(address) eeprom_read_word ((const uint16_t*)address)
#define write_eeprom_word(address,value) eeprom_write_word ((uint16_t*)address,(uint16_t)value)
#define read_eeprom_dword(address) eeprom_read_dword ((const uint32_t*)address)
#define write_eeprom_dword(address,value) eeprom_write_dword ((uint32_t*)address,(uint32_t)value)
#define read_eeprom_float(address) eeprom_read_float ((const float *)address)
#define write_eeprom_float(address,value) eeprom_write_float ((float*)address,(float)value)
#define read_eeprom_array(address,value_p,length) eeprom_read_block ((void *)value_p, (const void *)address, length)
#define write_eeprom_array(address,value_p,length) eeprom_write_block ((const void *)value_p, (void *)address, length)
uint8_t my_byte;
uint16_t my_word;
uint32_t my_dword;
float my_float;
char my_text[10]={"123456789#include <avr/eeprom.h>
// macro for eeprom access
#define read_eeprom_byte(address) eeprom_read_byte ((const uint8_t*)address)
#define write_eeprom_byte(address,value) eeprom_write_byte ((uint8_t*)address,(uint8_t)value)
#define read_eeprom_word(address) eeprom_read_word ((const uint16_t*)address)
#define write_eeprom_word(address,value) eeprom_write_word ((uint16_t*)address,(uint16_t)value)
#define read_eeprom_dword(address) eeprom_read_dword ((const uint32_t*)address)
#define write_eeprom_dword(address,value) eeprom_write_dword ((uint32_t*)address,(uint32_t)value)
#define read_eeprom_float(address) eeprom_read_float ((const float *)address)
#define write_eeprom_float(address,value) eeprom_write_float ((float*)address,(float)value)
#define read_eeprom_array(address,value_p,length) eeprom_read_block ((void *)value_p, (const void *)address, length)
#define write_eeprom_array(address,value_p,length) eeprom_write_block ((const void *)value_p, (void *)address, length)
uint8_t my_byte;
uint16_t my_word;
uint32_t my_dword;
float my_float;
char my_text[10]={"123456789%pre%"};
//--------------- code inside main-----------------
// these will be written at runtime (and stored in first run), data will not be included in the eep file
write_eeprom_byte(1,0x0A); // write in eeprom address 1 the value 0x0A
write_eeprom_word(3,0x0AAA); // write in eeprom starting from address 3 the value 0x0AAA
write_eeprom_dword(10,0x0AAAAAAA);// write in eeprom starting from address 10 the value 0x0AAAAAAA
write_eeprom_float(5,0.123456);// write in eeprom starting from address 5 the value 0.123456 , note it will occupy 4 bytes in eeprom 5,6,7,8
write_eeprom_array(10,my_text,8); // write in eeprom starting from address 10 the 8 first characters of my_text array
// and you can read them using
my_byte=read_eeprom_byte(1);
my_word=read_eeprom_word(3);
my_dword=read_eeprom_dword(10);
my_float=read_eeprom_float(5);
read_eeprom_array(10,my_text,5); // read to my_text array 5 char starting from eeprom address 10
"};
//--------------- code inside main-----------------
// these will be written at runtime (and stored in first run), data will not be included in the eep file
write_eeprom_byte(1,0x0A); // write in eeprom address 1 the value 0x0A
write_eeprom_word(3,0x0AAA); // write in eeprom starting from address 3 the value 0x0AAA
write_eeprom_dword(10,0x0AAAAAAA);// write in eeprom starting from address 10 the value 0x0AAAAAAA
write_eeprom_float(5,0.123456);// write in eeprom starting from address 5 the value 0.123456 , note it will occupy 4 bytes in eeprom 5,6,7,8
write_eeprom_array(10,my_text,8); // write in eeprom starting from address 10 the 8 first characters of my_text array
// and you can read them using
my_byte=read_eeprom_byte(1);
my_word=read_eeprom_word(3);
my_dword=read_eeprom_dword(10);
my_float=read_eeprom_float(5);
read_eeprom_array(10,my_text,5); // read to my_text array 5 char starting from eeprom address 10
No he incluido las funciones de actualización de eeprom, pero funcionan de manera similar