[an error occurred while processing this directive]
|
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.
Составить ответ ||| Конференция ||| Архив
Ответы
E-mail: info@telesys.ru