AVR的EEPROM簡單實驗
#include
#define uchar unsigned char
#define uint unsigned int
__flash uchar seg[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
__flash uchar tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
__flash uchar tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
#define EEWE 1
#define EERE 0
#define EEMWE 2
#define EERE 0
#define EEMWE 2
#define k1 PIND_Bit4 //地址變化鍵
#define k2 PIND_Bit5 //數(shù)據(jù)變化鍵
#define k3 PIND_Bit6 //地址寫入
#define k4 PIND_Bit7 //地址讀出
#define k2 PIND_Bit5 //數(shù)據(jù)變化鍵
#define k3 PIND_Bit6 //地址寫入
#define k4 PIND_Bit7 //地址讀出
uint val; //顯示的存儲數(shù)值
uchar address,data; //存儲地址和數(shù)值
void delay(uint k) //延遲函數(shù)
{
uint i,j;
for(i=0;i
}
void key1()
{
static uchar i,j;
if(k1==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k1==0)
{
i=1;j=0;
address++;
}
}
}
}
else
{
i=0;j=0;
}
}
{
static uchar i,j;
if(k1==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k1==0)
{
i=1;j=0;
address++;
}
}
}
}
else
{
i=0;j=0;
}
}
void key2()
{
static uchar i,j;
if(k2==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k2==0)
{
i=1;j=0;
data++;
}
}
}
}
else
{
i=0;j=0;
}
}
void show_val(uint k) //顯示數(shù)值函數(shù)
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
void show_address(uint k) //顯示數(shù)值函數(shù)
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+3];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+3];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
void show_data(uint k) //顯示數(shù)值函數(shù)
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+6];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+6];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
關(guān)鍵詞:
AVREEPROM簡單實
評論