本人第一次用keil编的程序,为什么编译的时候说i,j未定义呢,我明明在主函数定义了啊,请高手帮帮忙
# include <reg52.h>#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit dawr=P3^6;
sbit dacs=P3^2;
sbit P10=P1^0; //LED represent 1310nm
sbit P11=P1^1; //LED represent 1490nm
sbit P12=P1^2; //LED represent 1550nm
sbit P13=P1^3; //LED represent com
sbit P20=P2^0; //com
sbit P21=P2^1; //1550nm
sbit P22=P2^2; //1490nm
sbit P23=P2^3; //1310nm
void main()
{uchar val;
dula=0;
wela=0;
dacs=0;
dawr=0;
while(1) //设定一个2.5V的参考电压
{P0=130;
}
NORM:unit i,j,k,ll;
i=j=k=ll=0;
while(i<256&&j<256&&k<256)
{
val=P20*1000+P21*100+P22*10+P23;
switch(val)
{case 0001:
case 0000: goto ERRO_1;
case 1000: goto ERRO_2;
case 1001: i++;j=k=0;break;
case 1010: j++;i=k=0;break;
case 1011: i++;j++;k=0;break;
case 1100: k++;i=0;j=0;break;
case 1101: i++;k++;j=0;break;
case 1110: j++;k++;i=0;break;
case 1111:
default: i=j=k=0;break;
}
}
ERRO: if (i==256&&j==256) //failure in 1550nm
{while(1)
{P13=1;
P12=1;
P11=0;
P10=1;
}
}
else if (i==256&&k==256) //failure in 1490nm
{while(1)
{P13=1;
P12=0;
P11=1;
P10=1;
}
}
else if (j==256&&k==256) //failure in 1310nm
{while(1)
{P13=1;
P12=1;
P11=1;
P10=0;
}
}
else goto NORM;
ERRO_1:if (P20==0&&P23==1)//failure in com port
while (1)
{
P13=0;
P12=1;
P11=1;
P10=1;
}
else ll++
{if(ll<256) goto NORM;
else while(1) //failure in both 1310nm port and com port
{ P13=0;
P12=0;
P11=0;
P10=0;
}
}
ERRO_2:unit i,j,k,ll;
i=j=k=0;
while (i<256&&j<256)
{ if (P21==1&&P22==1)//故障排除
goto NORM
if (P21==0&&P22==1) i++;j=0;
if (P21==0&&P22==1) j++;i=0;
else i++;j++;
}
if (i==256) //failure in 1490nm
{while(1)
{P13=1;
P12=0;
P11=1;
P10=1;
}
}
else if (j==256) //failure in 1550nm
{while(1)
{P13=1;
P12=1;
P11=0;
P10=1;
}
}
}
[ 本帖最后由 flyfx1989 于 2011-7-1 22:04 编辑 ]