|
麻烦各位帮我看一看我的程序哪里有问题,拜托了,我是新手阿
[复制链接]
#include
#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--);
}
}
void OnRunning(void)
{
if(flag)
{
flag=0;
SetLED();
if(T>time1+time2+time3*60)
{
return;
}
else if(T>=(time1+time2))
{
if(sec05==2)
{
L1=OFF;
L2=ON;
L4=ON;
L3=OFF;
J=0x04;
}
}
else if(T>time1)
{
if(sec05==1)
{
L0=OFF;
L1=ON;
J=0x02;
L3=ON;
}
}
else
{
if(sec05==0)
{
L0=ON;
J=0x01;
L3=ON;
}
}
}
}
void SetLED(void)
{
if(sec>100)
{
buff[0]=sec/600;
buff[1]=sec/60-buff[0]*10;
}
else
{
buff[0]=sec/10;
buff[1]=sec-buff[0]*10;
}
}
void Reload(void)
{
if(T>time1+time2+time3*60)
{
return;
}
else if(T>=(time1+time2))
{
sec=time3*60;
return;
}
else if(T>=time1)
{
sec=time2;
return;
}
else
{
sec=time1;
return;
}
}
void Timer0_Interruput(void) interrupt 1
{
TR0 = 0;
TH0 = TIMER0H;
TL0 = TIMER0L;
TR0 = 1;
time++;
if(time==100)
{
T=T+1;
}
Index++;
Index &=0x01;
P0 = TableLED[buff[Index]];
switch ( Index )
{
case 0 :
P2 = 0X80 |J;
break;
case 1 :
P2 = 0X40 |J;
break;
}
pps ++;
if ( !flag_run) return;
if ( pps == 50 )
{
pps = 0;
sec05 ++;
flag = 1;
if ( sec05 == 3)
{
sec05 = 0;
sec -- ;
if (sec==0 )
{
Reload();
s = -s;
}
}
}
}
void InitDevice(void)
{
Index = 0;
pps = 0;
TH0 = TIMER0H;
TL0 = TIMER0L;
TMOD = 0X01;
TR0 = 1;
ET0 = 1;
EA = 1;
}
keil中提示的错误是 syntax error near 'unsigned'
|
|