现在的问题是 循环的第二次 dula 显示的就不是 一开始 的dula=0x08 le
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define dula P0
#define wela P2
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x79,0x38,0x3f,0};
void dispaly(uchar,uchar,uchar,uchar,uchar,uchar);
uchar t0,t1,num,num1,bai,shi,ge,aa,flay;
uint shu;
void delay(int);
void itin();
void main()
{
itin();
while(1)
{
if(num1==1)
{
dispaly(9,8,7,bai,shi,ge); //显示数码管
}
}
}
void itin()
{
dula=0x08;
shu=610;
flay=0;
TMOD=0x11;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t0++;
if(t0==20)
{
t0=0;
dula=_cror_(dula,1); //流水灯 位移
num++;
if(num==10)
{
num=0;
TR0=0;
flay=1;
}
}
}
void timer1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t1++;
if(flay==1)
{
num1=1;
if(t1==10)
{
t1=0;
shu--; //数减
if(shu==600)
{
num1=0;
flay=0;
dula=0x04;
TR0=1;
shu=610;
}
}
}
}
void dispaly(uchar aa,uchar bb,uchar cc,uchar bai,uchar shi,uchar ge)
{
bai=shu/100;
shi=shu%100/10;
ge=shu%10;
wela=0x7f;
dula=table[aa];
delay(1);
wela=0xbf;
dula=table[bb];
delay(1);
wela=0xdf;
dula=table[cc];
delay(1);
wela=0xef;
dula=table[bai];
delay(1);
wela=0xf7;
dula=table[shi];
delay(1);
wela=0xfb;
dula=table[ge];
delay(1);
}
void delay(int xsm)
{
int i,y;
for(i=xsm;i>0;i--)
for(y=110;y>0;y--);
}
|