TEXT1.C(58): error C141: syntax error near 'void'不知道错哪了,请问哪位大侠帮下小弟
#include"reg52.h"unsignedcharcodedis_7[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0...
#include"reg52.h"
unsigned char code dis_7[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
/*共阳led数码0,1,2,3,4,5,6,7,8,9,不亮*/
unsigned char code scan_con[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char data timedata[6]={0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char data dis[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char data con1s=0x00,con04s=0x00,con=0x00;
sbit key0=P1^0;
sbit key1=P1^1;
sbit key2=P1^2;
/****************************1ms延时函数**************************/
delay1ms(int t)
{
int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++)
;
}
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10) {dis[7]=dis[con];dis[con]=dis[6];dis[6]=dis[7];}
con++;TR0=0;ET0=0;TR1=1;ET1=1;
if(con>=6)
{con=0;TR1=0;ET1=0;TR0=1;ET0=1;}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{timedata[con]=0;}
dis[con]=timedata[con];dis[6]=0x0a;
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{timedata[con]=0x09;}
else {timedata[con]--;}
dis[con]=timedata[con];dis[6]=0x0a;
}
}
EA=1;
}
/**************************显示函数********************************/
void scan()
{
unsigned char k;
for(k=0;k<6;k++)
{
P0=dis_7[dis[k]];P2=scan_con[k];delay1ms(1);P2=0xff;
}
}
/**************************初始化函数******************************/
void clearmen()
{
unsigned char i;
for(i=0;i<6;i++)
{
dis[i]=timedata[i];}
TH0=0x3c;TL0=0xb0;
TH1=0x3c;TL1=0xb0;
TMOD=0x11;ET0=1;ET1=1;TR1=0;TR0=1;EA=1;
}
/***************************主函数**********************************/
main()
{
clearmen();
while(1)
{scan();
keyscan();
}
}
/**************************1s中断处理函数*****************************/
void time_intt0(void) interrupt 1
{
ET0=0;TR0=0;TH0=0x3c;TL0=0xb0;TR0=1;
con1s++;
if(con1s==20)
{
con1s=0x00;
timedata[0]++;
if(timedata[0]>=10)
{timedata[0]=0;timedata[1]++;
if(timedata[1]>=6)
{timedata[1]=0;timedata[2]++;
if(timedata[2]>=10)
{timedata[2]=0;timedata[3]++;
if(timedata[3]>=6)
{timedata[3]=0;timedata[4]++;
if(timedata[4]>=10)
{timedata[4]=0;timedata[5]++;}
if(timedata[5]==2)
if(timedata[4]==4) {timedata[4]=0;timedata[5]=0;}
}
}
}
}
dis[0]=timedata[0];dis[1]=timedata[1];dis[2]=timedata[2];
dis[3]=timedata[3];dis[4]=timedata[4];dis[5]=timedata[5];
}
ET0=1;
}
/***************************0.4s闪烁中断函数******************************/
void time_intt1(void) interrupt 3
{
EA=0;TR1=0;TH1=0x3c;TL1=0xb0;TR1=1;
con04s++;
if(con04s==8)
{
con04s=0x00;
dis[7]=dis[con];dis[con]=dis[6];dis[6]=dis[7];
}
EA=1;
}
/****************************结束************************************/
错误提示在scan()函数那里,现在很急
用的是at89c52,用keil弄的
希望是单片机编程高手,仅会c语言的就不用看了 展开
unsigned char code dis_7[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
/*共阳led数码0,1,2,3,4,5,6,7,8,9,不亮*/
unsigned char code scan_con[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char data timedata[6]={0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char data dis[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char data con1s=0x00,con04s=0x00,con=0x00;
sbit key0=P1^0;
sbit key1=P1^1;
sbit key2=P1^2;
/****************************1ms延时函数**************************/
delay1ms(int t)
{
int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++)
;
}
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10) {dis[7]=dis[con];dis[con]=dis[6];dis[6]=dis[7];}
con++;TR0=0;ET0=0;TR1=1;ET1=1;
if(con>=6)
{con=0;TR1=0;ET1=0;TR0=1;ET0=1;}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{timedata[con]=0;}
dis[con]=timedata[con];dis[6]=0x0a;
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{timedata[con]=0x09;}
else {timedata[con]--;}
dis[con]=timedata[con];dis[6]=0x0a;
}
}
EA=1;
}
/**************************显示函数********************************/
void scan()
{
unsigned char k;
for(k=0;k<6;k++)
{
P0=dis_7[dis[k]];P2=scan_con[k];delay1ms(1);P2=0xff;
}
}
/**************************初始化函数******************************/
void clearmen()
{
unsigned char i;
for(i=0;i<6;i++)
{
dis[i]=timedata[i];}
TH0=0x3c;TL0=0xb0;
TH1=0x3c;TL1=0xb0;
TMOD=0x11;ET0=1;ET1=1;TR1=0;TR0=1;EA=1;
}
/***************************主函数**********************************/
main()
{
clearmen();
while(1)
{scan();
keyscan();
}
}
/**************************1s中断处理函数*****************************/
void time_intt0(void) interrupt 1
{
ET0=0;TR0=0;TH0=0x3c;TL0=0xb0;TR0=1;
con1s++;
if(con1s==20)
{
con1s=0x00;
timedata[0]++;
if(timedata[0]>=10)
{timedata[0]=0;timedata[1]++;
if(timedata[1]>=6)
{timedata[1]=0;timedata[2]++;
if(timedata[2]>=10)
{timedata[2]=0;timedata[3]++;
if(timedata[3]>=6)
{timedata[3]=0;timedata[4]++;
if(timedata[4]>=10)
{timedata[4]=0;timedata[5]++;}
if(timedata[5]==2)
if(timedata[4]==4) {timedata[4]=0;timedata[5]=0;}
}
}
}
}
dis[0]=timedata[0];dis[1]=timedata[1];dis[2]=timedata[2];
dis[3]=timedata[3];dis[4]=timedata[4];dis[5]=timedata[5];
}
ET0=1;
}
/***************************0.4s闪烁中断函数******************************/
void time_intt1(void) interrupt 3
{
EA=0;TR1=0;TH1=0x3c;TL1=0xb0;TR1=1;
con04s++;
if(con04s==8)
{
con04s=0x00;
dis[7]=dis[con];dis[con]=dis[6];dis[6]=dis[7];
}
EA=1;
}
/****************************结束************************************/
错误提示在scan()函数那里,现在很急
用的是at89c52,用keil弄的
希望是单片机编程高手,仅会c语言的就不用看了 展开
2个回答
展开全部
你的这个问题是在显示函数上边最后再添加一个“}”符号就好了,我在我电脑里试了,可以编译了。
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10)
{
dis[7]=dis[con];
dis[con]=dis[6];
dis[6]=dis[7];
}
con++;
TR0=0;
ET0=0;
TR1=1;
ET1=1;
if(con>=6)
{
con=0;
TR1=0;
ET1=0;
TR0=1;
ET0=1;
}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{
timedata[con]=0;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{
timedata[con]=0x09;
}
else
{
timedata[con]--;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
EA=1;
}
或者
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10)
{
dis[7]=dis[con];
dis[con]=dis[6];
dis[6]=dis[7];
}
con++;
TR0=0;
ET0=0;
TR1=1;
ET1=1;
if(con>=6)
{
con=0;
TR1=0;
ET1=0;
TR0=1;
ET0=1;
}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{
timedata[con]=0;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{
timedata[con]=0x09;
}
else
{
timedata[con]--;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
}
EA=1;
}
两个我都编译了,都没出错。
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10)
{
dis[7]=dis[con];
dis[con]=dis[6];
dis[6]=dis[7];
}
con++;
TR0=0;
ET0=0;
TR1=1;
ET1=1;
if(con>=6)
{
con=0;
TR1=0;
ET1=0;
TR0=1;
ET0=1;
}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{
timedata[con]=0;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{
timedata[con]=0x09;
}
else
{
timedata[con]--;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
EA=1;
}
或者
/****************************键扫描子函数*************************/
keyscan()
{
EA=0;
if(key0==0)
{
delay1ms(10);
while(key0==0);
if(dis[con]==10)
{
dis[7]=dis[con];
dis[con]=dis[6];
dis[6]=dis[7];
}
con++;
TR0=0;
ET0=0;
TR1=1;
ET1=1;
if(con>=6)
{
con=0;
TR1=0;
ET1=0;
TR0=1;
ET0=1;
}
}
if(con!=0)
{
if(key1==0)
{
delay1ms(10);
while(key1==0);
timedata[con]++;
if(timedata[con]>=10)
{
timedata[con]=0;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
if(con!=0)
{
if(key2==0)
{
delay1ms(10);
while(key2==0);
if(timedata[con]==0)
{
timedata[con]=0x09;
}
else
{
timedata[con]--;
}
dis[con]=timedata[con];
dis[6]=0x0a;
}
}
}
EA=1;
}
两个我都编译了,都没出错。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询