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.
program EEPROM
dim counter as byte ' loop variable
main:
DDRA = 0xFF
DDRB = 0xFF
DDRC = 0xFF
for counter = 0 to 31 ' Fill data buffer
EEPROM_Write(0x100 + counter, counter) ' Write data to
address 0x100+counter
next counter
EEPROM_Write(0x02,0xAA) ' Write some data at address 2
EEPROM_Write(0x150,0x55) ' Write some data at address 0x150
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(0x02) ' Read data from
address 2 and display it on PORTA
PORTB = EEPROM_Read(0x150) ' Read data from
address 0x150 and display it on PORTB
Delay_ms(1000)
for counter = 0 to 31 ' Read 32 bytes block from address 0x100
PORTC = EEPROM_Read(0x100+counter) ' and display
data on PORTC
Delay_ms(100)
next counter
end.
213
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6