ATMEGA16-16AU SL602 Atmel, ATMEGA16-16AU SL602 Datasheet - Page 21

no-image

ATMEGA16-16AU SL602

Manufacturer Part Number
ATMEGA16-16AU SL602
Description
Manufacturer
Atmel
Datasheet
2466T–AVR–07/10
also assume that no Flash Boot Loader is present in the software. If such code is present, the
EEPROM write function must also wait for any ongoing SPM command to finish.
Assembly Code Example
C Code Example
EEPROM_write:
void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
}
; Wait for completion of previous write
sbic EECR,EEWE
rjmp EEPROM_write
; Set up address (r18:r17) in address register
out
out
; Write data (r16) to data register
out
; Write logical one to EEMWE
sbi
; Start eeprom write by setting EEWE
sbi
ret
/* 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);
;
EEARH, r18
EEARL, r17
EEDR,r16
EECR,EEMWE
EECR,EEWE
ATmega16(L)
21

Related parts for ATMEGA16-16AU SL602