在用keil C模拟串口接收GPS数据并发送给PC时发现问题:
例如:(接收,串口1,9600波特率)
$GPGGA,040002.000,3117.3760,N,12139.6764,E,1,07,2.2,41.7,M,8.4,M,,0000*5E
$GPGSA,A,3,30,16,21,07,06,13,23,,,,,,2.8,2.2,1.8*34
$GPGSV,3,1,12,06,81,063,36,16,56,013,43,23,48,262,31,30,39,053,46*72
(发送,串口0,1200波特率)
040002.000,3117.3760,N,12139.6764,E,1,07,2.2,41.7,M,8.4,M,,0000*5E
即只发送GPGGA(第一行)后的数据
但实际却在PC上看到:
PGSV,3,2,12,13,33,304,35,21,13
PGSV,3,3,12,25,36,320,,03,29,2
PGGA,040002.000,3117.3760,N,12
......
现将主要程序贴上,求各位大爷给点意见(PS: Init_Device()中各初始化均由SILICON软件配置,无问题):
void Uart1_ISR(void) interrupt 20
//中断接收Uart1
{
if((SCON1&0x01) == 0x01)
//RI_1=1
{
SCON1 = (SCON1&0xFE);
//RI_1=0
king = SBUF1;
EA = 0;
if((come == 1)&&(come1 == 0))
{
Address[d] = king;
d = d+1;
if(d == 4) d = 0;
if(Address[3] == 'G')
{ come = 0,come1 = 1;}
}
else if((come1 == 1)&&(come == 0))
{
GPS[e] = king;
e = e+1;
if(e == 45)
{e = 0,flag = 1,come = 0,come1 = 0;}
}
else if(king == '$') {come = 1,come1 = 0;}
EA = 1;
}
}
void main(void)
{
WDTCN = 0xDE;
//关狗
WDTCN = 0xAD;
Init_Device();
EIE2 = 0x40;
//开启串口1中断,即ES1=1
IE = 0x80;
//开总中断,即EA=1
while(1)
{
if(flag == 1)
{
EA = 0;
flag = 0;
neg = 1;
for(a = 0;a < 45;a++)
{
SBUF0 = GPS[a];
//查询发送Uart0
while(!TI0);
TI0 = 0;
Delay(10);
}
neg = 0;
Delay(300);
EA = 1;
}
}
} |