ATMEGA48V_11 ATMEL [ATMEL Corporation], ATMEGA48V_11 Datasheet - Page 26

no-image

ATMEGA48V_11

Manufacturer Part Number
ATMEGA48V_11
Description
8-bit Atmel Microcontroller with 4/8/16K Bytes In-System Programmable Flash
Manufacturer
ATMEL [ATMEL Corporation]
Datasheet
8.6.4
8.6.5
8.6.6
2545T–AVR–05/11
GPIOR2 – General purpose I/O register 2
GPIOR1 – General purpose I/O register 1
GPIOR0 – General purpose I/O register 0
The next code examples show assembly and C functions for reading the EEPROM. The exam-
ples assume that interrupts are controlled so that no interrupts will occur during execution of
these functions.
Bit
0x2B (0x4B)
Read/write
Initial value
Bit
0x2A (0x4A)
Read/write
Initial value
Bit
0x1E (0x3E)
Read/write
Initial value
Assembly code example
C code example
EEPROM_read:
unsigned char EEPROM_read(unsigned int uiAddress)
{
}
; Wait for completion of previous write
sbic EECR,EEPE
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
ret
/* Wait for completion of previous write */
while(EECR & (1<<EEPE))
/* Set up address register */
EEAR = uiAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from Data Register */
return EEDR;
;
r16,EEDR
MSB
MSB
MSB
R/W
R/W
R/W
7
0
7
0
7
0
R/W
R/W
R/W
6
0
6
0
6
0
R/W
R/W
R/W
5
0
5
0
5
0
R/W
R/W
R/W
4
0
4
0
4
0
R/W
R/W
R/W
3
0
3
0
3
0
R/W
R/W
R/W
ATmega48/88/168
2
0
2
0
2
0
R/W
R/W
R/W
1
0
1
0
1
0
LSB
R/W
LSB
R/W
LSB
R/W
0
0
0
0
0
0
GPIOR2
GPIOR1
GPIOR0
26

Related parts for ATMEGA48V_11