求助,keil错误 C141: syntax error near 'unsigned'请大家帮忙看看
//9999 秒倒计时器
#include<reg52.h>
delayx1ms(unsigned int k);
#define uint unsigned int
#define uchar unsigned char
sbit p24=P2^4;
sbit p25=P2^5;
sbit p26=P2^6;
sbit p27=P2^7;
sbit qiting=P3^5;
sbit zeng=P3^6;
sbit jian=P3^7;
void display(void);
uint ge,shi,bai,qian;
unsigned long int i=0,a=9999;
unsigned char table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void main()
{
//unsigned char table[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
TMOD=0X01; /*开定时器 T0,工作于方式 1*/
TL0=0XB0; /*50ms*/
TH0=0X3C;
ET0=1;
TR0=0;
EA=1; /*开中断*/
while(qiting)
{ display();
}
TR0=1;p27=1;delayx1ms(500);
while(a<10000)
if(qiting==0)
while(1)
{ p27=1;delayx1ms(1000);
while(qiting)
{ a=9999;TR0=0;if(qiting==0) break;
delayx1ms(200);
if(a==9999)
{
while(qiting==1)
{
display();
}
p27=1;
delayx1ms(500);
TR0=1;break;
}
if(qiting==1)
{
display();
}
}
}
delayx1ms(unsigned int k) /*延时 1ms 子程序*/
{
unsigned int m,n;
{
for(m=0;m<k;m++);
for(n=0;n<120;n++);
}
}
void time0_int(void) interrupt 1 //中断服务子程序 定时器中断
TL0=0XB0;
TH0=0X3C;
i++;
if(i==19)
{
i=0; /*i 清 0*/
a--;
}
void display(void)
{
if(zeng==0) { a++;delayx1ms(10);} //设置数值增减的快慢
if(jian==0) {a--;delayx1ms(10);}
qian=a/1000;
bai=a%1000/100;
shi=a%1000%100/10;
ge=a%10;
P0=table[qian] ;
p24=0;
p25=p26=p27=1;
delayx1ms(3);
P0=table[bai];
p24=1;p25=0;
delayx1ms(3);
P0=table[shi];
p25=1;p26=0;
delayx1ms(3);
P0=table[ge] ;
p26=1;p27=0;
delayx1ms(3);
}
9999.C(58): 错误 C141: syntax error near 'unsigned'
求大家帮我看看哪里错了
[解决办法]
语法问题给你解决了,逻辑可能有问题,需要你自己去调试了,编程一定要注意coding stye,你很多地方连括号都没写,有些地方括号不配对,上面的编译错误就是少了括号,自己对比一下你的代码吧,就不一一指出你的问题了。
//9999 秒倒计时器
#include<reg52.h>
void delayx1ms(unsigned int k);
#define uint unsigned int
#define uchar unsigned char
sbit p24=P2^4;
sbit p25=P2^5;
sbit p26=P2^6;
sbit p27=P2^7;
sbit qiting=P3^5;
sbit zeng=P3^6;
sbit jian=P3^7;
void display(void);
uint ge,shi,bai,qian;
unsigned long int i=0,a=9999;
unsigned char table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void main()
{
//unsigned char table[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
TMOD=0X01; /*开定时器 T0,工作于方式 1*/
TL0=0XB0; /*50ms*/
TH0=0X3C;
ET0=1;
TR0=0;
EA=1; /*开中断*/
while(qiting)
{ display();
}
TR0=1;p27=1;delayx1ms(500);
while(a<10000)
if(qiting==0)
while(1)
{ p27=1;delayx1ms(1000);
while(qiting)
{ a=9999;TR0=0;if(qiting==0) break;
delayx1ms(200);
if(a==9999)
{
while(qiting==1)
{
display();
}
p27=1;
delayx1ms(500);
TR0=1;break;
}
if(qiting==1)
{
display();
}
}
}
}
void delayx2ms(unsigned int k) /*延时 1ms 子程序*/
{
unsigned int m,n;
for(m=0;m<k;m++);
for(n=0;n<120;n++);
}
void time0_int(void) interrupt 1 //中断服务子程序 定时器中断
{
TL0=0XB0;
TH0=0X3C;
i++;
if(i==19)
{
i=0; /*i 清 0*/
a--;
}
}
void display(void)
{
if(zeng==0) { a++;delayx1ms(10);} //设置数值增减的快慢
if(jian==0) {a--;delayx1ms(10);}
qian=a/1000;
bai=a%1000/100;
shi=a%1000%100/10;
ge=a%10;
P0=table[qian] ;
p24=0;
p25=p26=p27=1;
delayx1ms(3);
P0=table[bai];
p24=1;p25=0;
delayx1ms(3);
P0=table[shi];
p25=1;p26=0;
delayx1ms(3);
P0=table[ge] ;
p26=1;p27=0;
delayx1ms(3);
}