感觉省略和不省略差不多,但dis=timedata有和没有竟然会影响到延时程序
#include<reg51.h>
#define uchar unsigned char
#define led_data P0
#define led_bit P2
int b=0;
uchar conls=0;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};
uchar data scan_con[6]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF};
//uchar data dis[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00};
uchar data timedata[6]={0x00,0x00,0x00,0x00,0x02,0x01};
display();
void delay(uchar z);
initializa();
void main()
{
initializa();
while(1)
{
display();
}
}
display()
{
uchar k;
for(k=0;k<6;k++)
{
led_data=table[timedata[k]];led_bit=scan_con[k];delay(1);P2=00;
}
}
void delay(int z)
{
int x,y;
for(x=0;x<z;x++)
for(y=0;y<120;y++);
}
initializa()
{
/*int i;
for(i=0;i<6;i++)
{
dis=timedata;
}*/
TH0=0X3C;TL0=0XB0;
TMOD=0x01;
ET0=1;
TR0=1;
EA=1;
}
void time_intt0(void)interrupt 1
{
ET0=0;TR0=0;TH0=0X3C;TL0=0XB0;TR0=1;
conls++;
if(conls==20)
{
conls=0x00;
timedata[0]++;
if(timedata[0]>=10)
{
timedata[0]=0;timedata[1]++;
if(timedata[1]>=6)
{
timedata[1]=0;timedata[2]++;
if(timedata[2]>=10)
{
timedata[2]=0;timedata[3]++;
if(timedata[3]>=6)
{
timedata[3]=0;timedata[4]++;
if(timedata[4]>=10)
{
timedata[4]=0;timedata[5]++;
}
if(timedata[5]==2)
{
if(timedata[4]==4)
{
timedata[4]=0;timedata[5]=0;
}
}
}
}
}
}
/*for(b=0;b<6;b++)
{
dis=timedata;
}*/
}
ET0=1;
} |