单片机课设E2PROM数据传送C程序Word格式.docx
《单片机课设E2PROM数据传送C程序Word格式.docx》由会员分享,可在线阅读,更多相关《单片机课设E2PROM数据传送C程序Word格式.docx(13页珍藏版)》请在冰豆网上搜索。
digit4[9]={0x99,0xff,0xdf,0x9f,0x9d,0x99,0xff,0x99,0xff},
digit5[10]={0x92,0xff,0xfe,0xde,0x9e,0x9a,0x92,0xff,0x92,0xff},
digit6[11]={0x82,0xff,0xfe,0xde,0xce,0xc6,0xc2,0x82,0xff,0x82,0xff},
digit7[8]={0xf8,0xff,0xfe,0xfc,0xf8,0xff,0xf8,0xff},
digit8[12]={0x80,0xff,0xfe,0xfc,0xbc,0xac,0xa4,0xa0,0x80,0xff,0x80,0xff},
digit9[11]={0x90,0xff,0xbf,0x9f,0x9e,0x9c,0x98,0x90,0xff,0x90,0xff};
voiddelay()
{;
;
}
voiddelay_nms(ucharn)
{
uchari,j;
for(i=n;
i>
0;
i--)
for(j=110;
j>
j--);
voiddelay_s(ucharn)
uchari;
i--)delay_nms(500);
voidI2C_init()
SDA=1;
delay();
SCL=1;
voidstart()
SDA=0;
}
voidstop()
voidrespons()
while((SDA==0)&
&
i<
255)i++;
SCL=0;
voidwritebyte(uchardat)
for(i=0;
8;
i++)
{
dat<
<
=1;
SCL=0;
delay();
SDA=CY;
SCL=1;
}
ucharreadbyte()
uchari,temp;
{
temp=(temp<
1)|SDA;
returntemp;
voidwrite_dat(ucharadd,uchardat)
start();
writebyte(0xa0);
respons();
writebyte(add);
writebyte(dat);
stop();
ucharread_dat(ucharadd)
uchardat;
writebyte(0xa1);
dat=readbyte();
returndat;
voiddisplay(uchardigit)
P0=table[digit];
voidkeyscan()
if(Shift==0)
{
delay_nms(10);
if(Shift==0)
{
while(!
Shift)
{
if(W==0)//pressShift+W
{
delay_nms(10);
if(W==0)flag2=0;
}
}
}
}
voidspe_display(ucharn)
switch(n)
case0:
for(i=0;
11;
P0=digit0[i];
keyscan();
if(flag2==0)
display(num);
break;
delay_s(8);
break;
case1:
7;
P0=digit1[i];
case2:
10;
P0=digit2[i];
case3:
P0=digit3[i];
case4:
9;
P0=digit4[i];
case5:
P0=digit5[i];
case6:
P0=digit6[i];
case7:
P0=digit7[i];
case8:
12;
P0=digit8[i];
case9:
P0=digit9[i];
/*********主函数***********/
voidmain()
I2C_init();
P1=0xff;
EA=1;
ET0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TMOD=0x01;
while
(1)
display(num);
if(flag2==1)
spe_display(num);
if(flag2==0)
if(Ctrl==0)//pressCtrl
delay_nms(40);
if(Ctrl==0)
while(!
Ctrl)
{display(num);
if(R==0)//pressCtrl+R
{
delay_nms(40);
if(R==0)
{
TR0=1;
count=0;
flag1=1;
}
}
if(W==0)//pressCtrl+W
if(W==0)
TR0=0;
flag1=0;
}
if(flag1==0)
if