帮忙看看下面的GPS接收代码有什么问题
void GPS_Recv( unsigned char r_char)
{
if (r_char==0x24){GPS_CMD_BUF=0;GPS_CMD_FLAG=1;GPS_CMD_INDEX=0;GPS_CMD_COUNT=0;}
if (GPS_CMD_FLAG==1)
{
GPS_CMD_BUF+=r_char;
GPS_CMD_COUNT++;
if(GPS_CMD_COUNT==7)
{
if (GPS_CMD_BUF==0xC9) //接收$GPRMC头指令
{
GPS_CMD_MODE=1;
GPS_CMD_EN=1;
GPS_CMD_INDEX=0;
GPS_CMD_ID=0;
GPS_CMD_COUNT=0;
}
else
{
GPS_CMD_FLAG=0;
GPS_CMD_EN=0;
GPS_CMD_COUNT=0;
}
}
}
if (GPS_CMD_EN==1&&GPS_CMD_MODE==1)
{
switch (r_char)
{
case 0x2c: // 此时接收逗号;
GPS_CMD_ID=0;
GPS_CMD_COUNT++;
break;
case 0x0a:
GPS_CMD_ID=0;
GPS_CMD_COUNT=0;
GPS_CMD_FLAG=0;
GPS_CMD_EN=0;
LED_COM1_RXD=~LED_COM1_RXD;
OUTPUT_GPS();
break;
case 0x0D:
break;
default:
switch (GPS_CMD_INDEX)
{
case 0: //时间
if (GPS_CMD_ID<=5){GPS_TIME[GPS_CMD_ID]=r_char;break;}
case 1: //有效标志
case 2: //纬度
if (GPS_CMD_ID<=8){GPS_WD[GPS_CMD_ID]=r_char;break;}
case 4: //经度
if (GPS_CMD_ID<=9){GPS_JD[GPS_CMD_ID]=r_char;break;}
case 6: //速度
if (GPS_CMD_ID<=4){GPS_SPEED[GPS_CMD_ID]=r_char;break;}
case 7: //方向
if (GPS_CMD_ID<=4){GPS_DEG[GPS_CMD_ID]=r_char;break;}
case 8 : //日期
if (GPS_CMD_ID<=5){GPS_DATE[GPS_CMD_ID]=r_char;break;}
}
GPS_CMD_ID++;
break;
}
}
}
void UART_two_Interrupt_Receive(void) interrupt 8
{
unsigned char k = 0;
k = S2CON ;
k = k & 0x01;
if(k==1)
{
LED_COM2_RXD=0;
S2CON = S2CON & 0xFE; //1111,1110
k = S2BUF;
send_UART_one(k);
GPS_Recv(k); //如果我吧这个函数屏蔽程序接收就正常了
LED_COM2_RXD=1;
}
else
{
S2CON = S2CON & 0xFD; //1111,1101
}
}
编译通过,烧程序也没问题,但是运行就没反应,GPS_Recv()这个函数我在TC2.0里面单步运行也是没有问题的,高手能回答我么 |