|
发表于 2009-5-6 02:05:49
|
显示全部楼层
查看CVAVR的HELP。这是基本要求和素质。
Accessing the AVR internal EEPROM is accomplished using global variables, preceded by the keyword eeprom.
Example:
/* The value 1 is stored in the EEPROM during chip programming */
eeprom int alfa=1;
eeprom char beta;
eeprom long array1[5];
/* The string is stored in the EEPROM during chip programming */
eeprom char string[]="Hello";
void main(void) {
int i;
/* Pointer to EEPROM */
int eeprom *ptr_to_eeprom;
/* Write directly the value 0x55 to the EEPROM */
alfa=0x55;
/* or indirectly by using a pointer */
ptr_to_eeprom=&alfa;
*ptr_to_eeprom=0x55;
/* Read directly the value from the EEPROM */
i=alfa;
/* or indirectly by using a pointer */
i=*ptr_to_eeprom;
}
Pointers to the EEPROM always use 16 bits. |
|