Datasheet
Library Example
This example demonstrates using the EEPROM Library with ATMEGA16 MCU.
First, some data is written to EEPROM in byte and block mode; then the data is read
from the same locations and displayed on PORTA, PORTB and PORTC.
char dat[32], ii; // Data buffer, loop variable
void main(){
DDRA = 0xFF; // set PORTA as output
DDRB = 0xFF; // set PORTB as output
DDRC = 0xFF; // set PORTC as output
for(ii = 31; dat[ii] = ii; ii--) // Fill data buffer
;
EEPROM_Write(2,0xAA); // Write some data at address 2
EEPROM_Write(0x732,0x55); // Write some data at address 0x732
EEPROM_Write_Block(0x100,dat); // Write 32 bytes block at
address 0x100
Delay_ms(1000); // Blink PORTA and PORTB diodes
PORTA = 0xFF; // to indicate reading start
PORTB = 0xFF;
Delay_ms(1000);
PORTA = 0x00;
PORTB = 0x00;
Delay_ms(1000);
PORTA = EEPROM_Read(2); // Read data from address 2
and display it on PORTA
PORTB = EEPROM_Read(0x732); // Read data from address
0x732 and display it on PORTB
Delay_ms(1000);
for(ii = 0; ii < 32; ii++) { // Read 32 bytes block from
address 0x100
PORTC = EEPROM_Read(0x100+ii); // and display data on PORTC
Delay_ms(100);
}
}
277
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6