单片机程序如下,用keil编译之后就说语法错误,可是本人实在看不出来为什么,希望大佬帮我解答,谢谢!
#include<reg52.h>
sbit led1=P1^0;
sbit wei=P2^7;
sbit duan=P2^6;
#define uint unsigned int;
#define uchar unsigned char;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uint num1,num2,n;
void delayms(uint);
void main()
{
TMOD=0x11;
EA=1;
ET0=1;
ET1=1;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
TR0=1;
TR1=1;
while(1)
{
wei=1;
P0=0xfe;
wei=0;
P0=0xff;
duan=1;
P0=table[n/10];
duan=0;
P0=0xfe;
delayms(1);
wei=1;
P0=0xfd;
wei=0;
P0=0xfe;
duan=1;
P0=table[n%10];
duan=0;
P0=0xfe;
delayms(1);
}
}
void delayms(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void T0_time() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
num1++;
if(num1==4)
{
num1=0;
led1=~led1;
}
}
void T1_time() interrupt 3
{
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
num2++;
if(num2==20)
{
num2=0;
n++;
if(n==59)
n=0;
}
}
|