Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
EEPROM_Write
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;
var counter : byte;                               // loop variable
begin
DDRA := 0xFF;
DDRB := 0xFF;
DDRC := 0xFF;
for counter := 0 to 31 do
// Fill data buffer
EEPROM_Write(0x100 + counter, counter);         // Write data to address
0x100+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;
228
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure EEPROM_Write(address: word; wrdata: byte);
Returns
Nothing. 
Description
Writes wrdata to specified address. 
Parameters : 
address
: address of the EEPROM memory location to be written. 
wrdata
: data to be written. 
Note: Specified memory location will be erased before writing starts.
Requires
Nothing.
Example
var eeWrite : byte;
wrAddr : word;
...
address := 0x02;
wrdata := 0xAA;
EEPROM_Write(wrAddr, eeWrite);