在keil4中运行如下代码会报“WORK3.C(20): error C141: syntax error near 'unsigned'”的错,求大神帮助
代码:#include<reg51.h>#defineTIMER0H0xD8#defineTIMER0L0XF0#defineucharunsignedchar#defi...
代码:
#include <reg51.h>
#define TIMER0H 0xD8
#define TIMER0L 0XF0
#define uchar unsigned char
#define ON 0
#define OFF 1
TableLED [] = { 0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F };
sbit L0 = P1^0;
sbit L1 = P1^1;
sbit L2 = P1^2;
sbit L3 = P1^3;
sbit L4 = P1^4;
sbit KEY_UP = P1^5;
sbit KEY_DW = P1^6;
sbit KEY_ST = P1^7;
sbit KEY_T2 = P3^2;
sbit KEY_T3 = P3^3;
uchar code
uchar preSet; (总是报这里出错)
uchar Index;
uchar buff[2];
uchar flag;
uchar time,T,J;
uchar pps;
uchar sec;
uchar sec05;
uchar s;
uchar flag_run;
uchar time1,time2,time3;
void InitDevice(void);
void SetLED(void);
void Reload(void);
void OnRunning(void);
void Delay(uchar u);
void OnSetting(void);
main()
{
InitDevice();
time1 = 10;
time2 = 20;
time3 = 6;
time = 0;
T = 0;
flag = 0x00;
sec = 0;
s = 0;
sec05 = 0;
Reload();
L0 = ON;
L1 = OFF;
L2 = OFF;
L3 = ON;
L4 = OFF;
flag_run = 1;
while(1)
{
if(KEY_ST==1)
{
OnRunning();
}
else
{
OnSetting();
}
}
}
void OnSetting(void)
{
Delay(4);
while(!KEY_ST);
flag_run = 0;
while(1)
{
if(!KEY_UP)
{
Delay(4);
while(!KEY_UP);
time1++;
time2++;
time3++;
if(time1>99) time1 = 1;
if(time2>99) time2 = 1;
if(time3>99) time3 = 1;
Reload();
SetLED();
}
if(!KEY_DW);
{
Delay(4);
while(!KEY_DW);
time1--;
time2--;
time3--;
if(time1<0) time1=99;
if(time2<0) time2=99;
if(time3<0) time3=99;
Reload();
SetLED();
}
if(!KEY_ST)
{
Delay(4);
while(!KEY_ST);
flag_run = 1;
return;
}
}
}
void Delay(uchar u)
{
int i;
while(u--)
{
i = 1000;
while(i--);
}
}
下面还有running等几个方法,但是代码编写没有错,就是定义无符号变量的时候出错了,求解答,急用。3q。 展开
#include <reg51.h>
#define TIMER0H 0xD8
#define TIMER0L 0XF0
#define uchar unsigned char
#define ON 0
#define OFF 1
TableLED [] = { 0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F };
sbit L0 = P1^0;
sbit L1 = P1^1;
sbit L2 = P1^2;
sbit L3 = P1^3;
sbit L4 = P1^4;
sbit KEY_UP = P1^5;
sbit KEY_DW = P1^6;
sbit KEY_ST = P1^7;
sbit KEY_T2 = P3^2;
sbit KEY_T3 = P3^3;
uchar code
uchar preSet; (总是报这里出错)
uchar Index;
uchar buff[2];
uchar flag;
uchar time,T,J;
uchar pps;
uchar sec;
uchar sec05;
uchar s;
uchar flag_run;
uchar time1,time2,time3;
void InitDevice(void);
void SetLED(void);
void Reload(void);
void OnRunning(void);
void Delay(uchar u);
void OnSetting(void);
main()
{
InitDevice();
time1 = 10;
time2 = 20;
time3 = 6;
time = 0;
T = 0;
flag = 0x00;
sec = 0;
s = 0;
sec05 = 0;
Reload();
L0 = ON;
L1 = OFF;
L2 = OFF;
L3 = ON;
L4 = OFF;
flag_run = 1;
while(1)
{
if(KEY_ST==1)
{
OnRunning();
}
else
{
OnSetting();
}
}
}
void OnSetting(void)
{
Delay(4);
while(!KEY_ST);
flag_run = 0;
while(1)
{
if(!KEY_UP)
{
Delay(4);
while(!KEY_UP);
time1++;
time2++;
time3++;
if(time1>99) time1 = 1;
if(time2>99) time2 = 1;
if(time3>99) time3 = 1;
Reload();
SetLED();
}
if(!KEY_DW);
{
Delay(4);
while(!KEY_DW);
time1--;
time2--;
time3--;
if(time1<0) time1=99;
if(time2<0) time2=99;
if(time3<0) time3=99;
Reload();
SetLED();
}
if(!KEY_ST)
{
Delay(4);
while(!KEY_ST);
flag_run = 1;
return;
}
}
}
void Delay(uchar u)
{
int i;
while(u--)
{
i = 1000;
while(i--);
}
}
下面还有running等几个方法,但是代码编写没有错,就是定义无符号变量的时候出错了,求解答,急用。3q。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询