You are on page 1of 5

AVR EEPROM

CodeVisionAVR EEPROM.PRJ
C:\cvavr\EXAMPLES\EEPROM CodeVisionAVR
Atmel 162 WinAVR

CodeVisionAVR 1 Flash f[]="This is a


test"; ptr_to_flash=f; 16Byte EEPROM
eeprom char e[16]; *ptr_to_eeprom ptr_to_eeprom=e;
char r[16]; RAM ptr_to_ram=r;

flash char f[]="This is a test";

Char flash *ptr_to_flash;

ptr_to_flash=f;

eeprom char e[16];

Char eeprom *ptr_to_eeprom;

ptr_to_eeprom=e;

char r[16];

char *ptr_to_ram;

ptr_to_ram=r;

"This is a test" EEPROM While() While() 0


( flash char f[]="This is a test"; CodeVisionAVR 0x00)
EEPROM 0x00 CodeVisionAVR
EEPROM 0x00 WinAVR EEPROM
0x00
while (*ptr_to_flash)
{
*ptr_to_eeprom++=*ptr_to_flash++;
}
*ptr_to_eeprom++=0x00; // 0x00, 0 ,

EEPROM char r[16]; 0


While()
while (*ptr_to_eeprom)
{
*ptr_to_ram++=*ptr_to_eeprom++;
}

1Byte 1Byte
0x06 char temp;
//save 1 byte to EEPROM designate address
ptr_to_eeprom=0x06;
// eeprom 0x06
*ptr_to_eeprom=0x52;
// 0x06=0x52
//read 1 byte form EEPROM designate address
ptr_to_eeprom=0x06;
// eeprom 0x06
temp=*ptr_to_eeprom;
// 0x06=0x52

flash char f[]="This is a test"; Flash 0x00

//
#include <mega162.h>
//-------------------------------------------//
//-------------------------------------------void initial(void); //
//-------------------------------------------// Declare your global variables here
//-------------------------------------------//
flash char f[16]="This is a test";
#pragma warneeprom char e[16];
#pragma warn+
char r[16];
char temp;

//********************************************************************************
//
//********************************************************************************
void main(void)
{
initial();
//CodeVisionAVR set
while (1)
{
char flash *ptr_to_flash;
char eeprom *ptr_to_eeprom;
char *ptr_to_ram;
// copy the string f from FLASH to
// the string e in EEPROM
ptr_to_flash=f;
ptr_to_eeprom=e;
while (*ptr_to_flash)
{
*ptr_to_eeprom++=*ptr_to_flash++;
}
*ptr_to_eeprom++=0x00; // 0, 0 ,
// copy the string e from EEPROM to
// the string r in RAM
ptr_to_eeprom=e;
ptr_to_ram=r;
while (*ptr_to_eeprom)
{
*ptr_to_ram++=*ptr_to_eeprom++;
}
//save 1 byte to EEPROM designate address
ptr_to_eeprom=0x06;
// eeprom 0x06
*ptr_to_eeprom=0x52;
// 0x06=0x52
//read 1 byte form EEPROM designate address
ptr_to_eeprom=0x06;
// eeprom 0x06
temp=*ptr_to_eeprom;
// 0x06=0x52
while (1);
}
}

//stop here

Name
Bloghttp://blog.xuite.net/likelive
2007/08/04

You might also like