数码管冲432减到398的时候 流水灯不会流,就是第一个灯一直亮着,我设计师想让他们都是进行 到398的时候 流水灯停止
我显示试出把定时器1的eles的语句去掉可以正常工作 一加上就流水灯不动了 不知道这么分析啊 ,都死磕3天了 还是不知道这么回事
#include <reg52.h> //52??????
#include <intrins.h> //??????????????
#define uint unsigned int //???
#define uchar unsigned char //???
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x79,0x38,0x3f,0};
uchar flag,bai,shi,ge,bb,flag1;
uint num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar a,uchar b,uchar c,uchar ba,uchar sh,uchar g)
{
wela=1; //??? //
P0=0xfe; //?????????
wela=0; //???
dula=1; //???
P0=table[a]; //???
dula=0; //???
P0=0xff;
delay(5);
wela=1; //???
P0=0xfd; //?????????
wela=0; //???
dula=1; //???
P0=table[b]; //???
dula=0; //???
P0=0xff;
delay(5);
wela=1; //???
P0=0xfb; //?????????
wela=0; //???
dula=1; //???
P0=table[c]; //???
dula=0; //???
P0=0xff;
delay(5);
wela=1; //???
P0=0xf7; //?????????
wela=0; //???
dula=1; //???
P0=table[ba]; //???
dula=0; //???
P0=0xff;
delay(5);
wela=1; //???
P0=0xef; //?????????
wela=0; //???
dula=1; //???
P0=table[sh]; //???
dula=0; //???
P0=0xff;
delay(5);
wela=1; //???
P0=0xdf; //?????????
wela=0; //???
dula=1; //???
P0=table[g]; //???
dula=0; //???
P0=0xff;
delay(5);
}
void init()
{
bb=0xfe;
P1=bb;
num=432;
TMOD=0X11;
TH0=(65536-45872)/256;//50o??
TL0=(65536-45872)%256;
TH1=(65536-45872)/256;//50o??
TL1=(65536-45872)%256;
EA=1;
ET0=1;
ET1=1;
TR1=1;
TR0=1;
}
void main()
{
init();
while(1)
{
//if(flag!=1)
display(7,6,5,bai,shi,ge);
//else
//dispaly(16,17,18,18,19,20);
}
}
void T1_1() interrupt 3
{
uchar tt;
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
tt++;
if(tt==2)
{
tt=0;
num--;
bai=num/100;
shi=num%100/10;
ge=num%10;
if(num==398)
{
TR1=0;
//TR0=0;
//flag1=1;
}
}
}
void T0_0() interrupt 1
{
uchar aa;
TH0=(65536-45872)/256;//50o??
TL0=(65536-45872)%256;
aa++;
if(flag1!=1)
{
if(aa==10)
{
aa=0;
bb=_crol_(bb,1);
P1=bb;
if(TR1==0)
{
TR0=0;
P1=0xff;
//aa=0;
flag1=1;
}
}
}
else
{
TR0=1;
aa=0;
// TH0=(65536-45872)/256;//50o??
// TL0=(65536-45872)%256;
if(aa%4==0)
{
//aa=0;
P1=~P1;
}
if(aa==60)
{
TR0=0;
P1=0xff;
}
}
}
|