Initializing EEPROM
EEPROM can be initialized in your program source file by allocation global variable to a special area called "eeprom." In C source, this can be done using pragmas. See Program Areas for discussion on different program areas. The resulting file is .eep. For example,#pragma data:eepromint foo = 0x1234;char table[] = { 0, 1, 2, 3, 4, 5 };#pragma data:data...int i;EEPROM_READ((int)&foo, i); // i now has 0x1234The second pragma is necessary to reset data area name back to the default "data."Note that to work around the hardware bug in AVR, location 0 is not used for initialized EEPROM data.Note that when using in an external declaration (e.g. accessing foo in another file), you do not use the pragma. For example, in another file:extern int foo;int i;EEPROM_READ((int)&foo, i); Составить ответ ||| Конференция ||| Архив Ответы Ответ: А что значит int foo = 0x1234 ??? — mapic (22.09.2004 16:32, пустое) Перейти к списку ответов ||| Конференция ||| Архив ||| Главная страница ||| Содержание ||| Без кадра E-mail: info@telesys.ru
#pragma data:eeprom
int foo = 0x1234;
char table[] = { 0, 1, 2, 3, 4, 5 };
#pragma data:data
...
int i;
EEPROM_READ((int)&foo, i); // i now has 0x1234
The second pragma is necessary to reset data area name back to the default "data."
Note that to work around the hardware bug in AVR, location 0 is not used for initialized EEPROM data.
Note that when using in an external declaration (e.g. accessing foo in another file), you do not use the pragma. For example, in another file:
extern int foo;
EEPROM_READ((int)&foo, i);
E-mail: info@telesys.ru