#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
void xianshi(uchar,uchar);
void delay(uint);
uint n1=0,n2=0,num=0;
uchar ge,shi;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit led=P1^0;
sbit duan=P2^6;
sbit wei=P2^7;
void main()
{
TMOD=0x11;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
while(1)
{
xianshi(shi,ge);
}
}
void xianshi(uchar,uchar)
{
duan=1;
P0=table[shi];
duan=0;
P0=0xff;
P0=0xfe;
delay(5);
duan=1;
P0=table[ge];
duan=0;
P0=0xff;
P0=0xfd;
delay(5);
}
void delay(uint j)
{
uint x,y;
for(x=j;x>0;x--)
for(y=110;y>0;y--);
}
void
time0() interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
n1++;
if(n1==20)
{
n1=0;
led=~led;
}
}
void time1() interrupt 3
{
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
n2++;
if(n2==20)
{
n2=0;
ge=num%10;
shi=num/10;
num++;
if(num==60)
num=0;
}
}
keil c51
就一个错误,帮忙看下啊
一周热门 更多>