在用C8051F020发送GPS数据的时候发现的问题:
例如:(接收,串口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
$GPGSV,3,2,12,13,33,304,35,21,13,056,39,07,08,313,39,19,78,115,*76
$GPGSV,3,3,12,25,36,320,,03,29,222,,31,24,120,,26,11,321,*70
$GPRMC,040002.000,A,3117.3760,N,12139.6764,E,0.20,168.43,310712,,,A*69
(发送,串口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
PRMC,040002.000,A,3117.3760,N,
PGGA,040002.000,3117.3760,N,12
PGSA,A,3,30,16,21,07,06,13,23,
PGSV,3,1,12,06,81,063,36,16,56
PGSV,3,2,12,13,33,304,35,21,13
PGSV,3,3,12,25,36,320,,03,29,2
现将主要程序贴上,求各位大爷给点意见(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;
}
}
}
此帖出自
小平头技术问答
一周热门 更多>