新手求助 数组给变量赋值后无结果
时间:10-02
整理:3721RD
点击:
求教大神 刚开始学习单片机 试着写了一个电子钟函数 函数就是运行不出结果来 检测时发现d=LED[i]这一句执行后无法给d赋值 求教啊 为什么啊
#include <reg52.h>
#include <intrins.h>
sbit DULA=P2^6;
sbit WELA=P2^7;
unsigned char i;
unsigned char data h,m,s;
unsigned char lie,tt,d;
unsigned int a;
unsigned char data LED[];
unsigned char code table[]={0x3f,0x06,0x5b, 0x4f , 0x66 , 0x6d
,0x7d , 0x07 , 0x7f , 0x6f, 0x77, 0x7c,
0x39 , 0x5e , 0x79 , 0x71 } ;
void main ()
{
lie=0xfe;
TMOD=0x01;
EA=1;
EX0=1;
IT0=1;
ET0=1;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt=0;
while(1)
{
s=tt/2;
if(s==60) {m++;s=0;tt=0;}
if(m==60) {h++;m=0;}
if(h==12) {h=0;}
LED[0]=s%10;
LED[1]=s/10;
LED[2]=m%10;
LED[3]=m/10;
LED[4]=h%10;
LED[5]=h/10;
for(i=0;i<6;i++)
{
WELA=1;
P0=b;
lie=_crol_(lie,1);
WELA=0 ;
DULA=1;
d=LED[i];
P0=table[d];
DULA=0; a=10;
while(a--);
}
}
}
void enter0() interrupt 0
{P1=0;
a=50000;
while(a--);
P1=0xff;
}
void time0() interrupt 1
{TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++ ;
}
#include <reg52.h>
#include <intrins.h>
sbit DULA=P2^6;
sbit WELA=P2^7;
unsigned char i;
unsigned char data h,m,s;
unsigned char lie,tt,d;
unsigned int a;
unsigned char data LED[];
unsigned char code table[]={0x3f,0x06,0x5b, 0x4f , 0x66 , 0x6d
,0x7d , 0x07 , 0x7f , 0x6f, 0x77, 0x7c,
0x39 , 0x5e , 0x79 , 0x71 } ;
void main ()
{
lie=0xfe;
TMOD=0x01;
EA=1;
EX0=1;
IT0=1;
ET0=1;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt=0;
while(1)
{
s=tt/2;
if(s==60) {m++;s=0;tt=0;}
if(m==60) {h++;m=0;}
if(h==12) {h=0;}
LED[0]=s%10;
LED[1]=s/10;
LED[2]=m%10;
LED[3]=m/10;
LED[4]=h%10;
LED[5]=h/10;
for(i=0;i<6;i++)
{
WELA=1;
P0=b;
lie=_crol_(lie,1);
WELA=0 ;
DULA=1;
d=LED[i];
P0=table[d];
DULA=0; a=10;
while(a--);
}
}
}
void enter0() interrupt 0
{P1=0;
a=50000;
while(a--);
P1=0xff;
}
void time0() interrupt 1
{TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++ ;
}
