|
发表于 2005-4-22 13:23:00
|
显示全部楼层
谢谢!这是一个笔误。
下面是ICC的HELP中的解释。
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 <output file>.eep. For example,
#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;
int i;
EEPROM_READ((int)&foo, i);
正确的定义方法是:
#pragma data:eeprom
......
......
#pragma data:data
然后生成一个.eep文件。该文件在下载程序执行代码后,再下载到EEPROM中。具体讲就是:
1。下载HEX文件,将HEX写入AVR的FLASH中
2。下载EEP文件,将EEP写入AVR的EEPROM中
在下载EEP文件时,可以在PC的下载软件中查看EEP文件的内容,它就是你定义的数据,同时也能知道写入EEPROM中的地址。如果第二部不做的话,EEPROM中不会有你初始定义的数据。 |
|