标题:
error C141: syntax error near 'unsigned'
[打印本页]
作者:
beautifulfish
时间:
2020-12-23 15:09
标题:
error C141: syntax error near 'unsigned'
求大佬帮看看这个程序怎么改吗?谢谢各位了!
报错的内容是:011.c(99): error C141: syntax error near 'unsigned'
代码如下:
#include<reg51.h>
sbit A1=P1^0;
sbit B1=P1^1;
sbit C1=P1^2;
sbit D1=P1^3;
#define WDM P0
#define KeyP3 P3
sbit DuanSuo=P2^2;
sbit WeiSuo=P2^3;
unsigned char Speed=1;
bit StopFlag=1;
unsigned char code DWtable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char code WMtable[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char TData[8];
#define A_ON {A1=1;B1=0;C1=0;D1=0;}
#define B_ON {A1=0;B1=1;C1=0;D1=0;}
#define C_ON {A1=0;B1=0;C1=1;D1=0;}
#define D_ON {A1=0;B1=0;C1=0;D1=1;}
#define AB_ON {A1=1;B1=1;C1=0;D1=0;}
#define BC_ON {A1=0;B1=1;C1=1;D1=0;}
#define CD_ON {A1=0;B1=0;C1=1;D1=1;}
#define DA-ON {A1=1;B1=0;C1=0;D1=1;}
#define ABCD_OFF {A1=0;B1=0;C1=0;D1=0;}
void DelayUs(unsigned char tu)
{
while(--tu);
}
void DelayMs(unsigned char tm)
{
while(tm--);
{
DelayUs (248);
DelayUs (248);
}
}
void Display(unsigned char ShiWei,unsigned char WeiShu)
{
static unsigned char i;
WDM=WMtable[i+ShiWei];
WeiSuo=1;
WeiSuo=0;
WDM=TData[i];
DuanSuo=1;
DuanSuo=0;
i++;
if(i==WeiShu)
{
i=0;
}
}
void T0Int_S (void)
{
TMOD=0X01;
TH0=0;
TL0=0;
EA=1;
ET0=1;
TR0=1;
}
void T0Int_Z (void) interrupt 1
{
static unsigned char times,i;
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;
Display(0,8);
if(StopFlag==0)
{
if(times==(20-Speed))
{
times=0;
switch(i)
{
case 0:A_ON;i++;break;
case 1:B_ON;i++;break;
case 2:C_ON;i++;break;
case 3:D_ON;i++;break;
case 4:i=0;break;
default:break;
}
}
times++;
}
unsigned char KeyS(void)//报错的是这行,应该怎么改,谢谢!!
{
unsigned char keyZ;
if(KeyP3!=0xff)
{
DelayMs(10);
if(KeyP3!=0Xff)
{
keyZ=KeyP3;
while(KeyP3!=0xff);
switch(keyZ)
{
case 0xfe:return 1;break;
case 0xfd:return 2;break;
case 0xfb:return 3;break;
case 0xf7:return 4;break;
case 0xef:return 5;break;
case 0xdf:return 6;break;
case 0xbf:return 7;break;
case 0x7f:return 8;break;
default:return 0;break;
}
}
}
return 0;
}
void main()
{
unsigned char num;
T0Int_S();
ABCD_OFF
while(1)
{
num=KeyS();
if(num==1)
{
if(Speed<18)
Speed++;
}
else if(num==2)
{
if(Speed>1)
Speed--;
}
else if(num==3)
{
ABCD_OFF
StopFlag=1;
}
else if(num==4)
{
StopFlag=0;
}
TData[0]=DMtable[Speed/10];
TData[1]=DMtable[Speed%10];
}
}
复制代码
作者:
beautifulfish
时间:
2020-12-23 15:40
我解决了,是因为变量定义要放在最前头,打扰了各位了
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1