Главная Случайная страница Контакты | Мы поможем в написании вашей работы! | ||
|
EEPROM_write:
; Wait for completion of previous write
Sbic EECR,EEWE
Rjmp EEPROM_write
; Set up address (r18:r17) in address register
Out EEARH, r18
Out EEARL, r17
; Write data (r16) to data register
Out EEDR,r16
; Write logical one to EEMWE
Sbi EECR,EEMWE
; Start eeprom write by setting EEWE
Sbi EECR,EEWE
Ret
C Code Example
Void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE));
/* Set up address and data registers */
EEAR = uiAddress;
EEDR = ucData;
/* Write logical one to EEMWE */
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
}
Считывание из EEPROM
Assembly Code Example
EEPROM_read:
; Wait for completion of previous write
Sbic EECR,EEWE
Rjmp EEPROM_read
; Set up address (r18:r17) in address register
Out EEARH, r18
Out EEARL, r17
; Start eeprom read by writing EERE
Sbi EECR,EERE
; Read data from data register
In r16,EEDR
Ret
C Code Example
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;
}
Дата публикования: 2015-09-18; Прочитано: 317 | Нарушение авторского права страницы | Мы поможем в написании вашей работы!