Пн июл 26, 2021 12:33:23
Пн июл 26, 2021 12:57:23
Пн июл 26, 2021 13:07:02
Пн июл 26, 2021 13:15:35
Вт июл 27, 2021 00:34:24
Вт июл 27, 2021 06:31:45
Вт июл 27, 2021 08:15:30
/* ---------- */
// Функции чтения и записи в еепром одного байта.
/* ---------- */
void EEPROM_write (unsigned int uiAddress, unsigned char ucData)
{
unsigned char cSREG;
/* Wait for completion of previous write */
while(EECR & (1<<EEWE));
/* Set up address and data registers */
EEAR = uiAddress;
EEDR = ucData;
cSREG = SREG; /* store SREG value */
/* disable interrupts during timed sequence */
#if __CODEVISIONAVR__ /* if CodeVisionAVR */
#asm("cli");
#else
asm("cli");
#endif
/* Write logical one to EEMWE */
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
SREG = cSREG; /* restore SREG value (I-bit) */
}
unsigned char EEPROM_read(unsigned int uiAddress)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE));
/* Set up address register */
EEAR = uiAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from data register */
return EEDR;
}
Вт июл 27, 2021 10:27:03
void EEPROM_write (unsigned int uiAddress, unsigned char ucData)
Вт июл 27, 2021 10:47:47
Определение функции
Каждая функция в языке Си должна быть определена, то есть должны быть указаны:
* тип возвращаемого значения;
* имя функции;
* информация о формальных аргументах;
* тело функции.
Определение функции имеет следующий синтаксис:
ТипВозвращаемогоЗначения ИмяФункции(СписокФормальныхАргументов)
{
ТелоФункции;
...
return(ВозвращаемоеЗначение);
}
EEAR = 0x0056;
EEDR = 0x78;
Вт июл 27, 2021 15:35:14
Вт июл 27, 2021 19:32:12
Вт июл 27, 2021 20:18:50
Вт июл 27, 2021 22:26:08
Ср июл 28, 2021 08:29:32
3.14 Accessing the EEPROM
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.
Ср июл 28, 2021 09:41:08
Ср июл 28, 2021 23:32:48
Чт июл 29, 2021 08:27:11
char eeprom *ptr_to_eeprom;
char *ptr_to_ram;
while (*ptr_to_eeprom)
*ptr_to_ram++=*ptr_to_eeprom++;
uint8_t StringOfData[10];
eeprom_read_block((void*)&StringOfData, (const void*)12, 10);
Чт июл 29, 2021 23:45:09
Пт июл 30, 2021 11:19:48
Чт авг 05, 2021 23:12:22