• 大小: 41KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: 其他
  • 标签: GPS  单片机  

资源简介

单片机通过串口接收来自GPS模块的数据帧 并识别帧头 最后取出其中的有效序列在LCD12864上显示 单片机采用AT89C51

资源截图

代码片段和文件信息

#include 
#include “LCD12864.h“

#define frame_LENGTH   (72)    //should >= 72
#define RECEIVE_ENABLE   (0X01)
#define RECEIVE_FINISH (0X00)
#define TIMEZONE (8)

unsigned char frameCache[frame_LENGTH];
unsigned char receiveStatusFlag;
unsigned char frameSignal;
unsigned char *framePoint;

void sendCharCom(unsigned char *ch)  
{   
while(*ch++!=‘\0‘)
   {
     SBUF=*ch;
     while(TI==0);
     TI=0;
}   
}

void getTime(void)
{
unsigned char timeString[9];
unsigned char hour;
hour = ((10*(frameCache[7] - 0x30) + (frameCache[8] - 0x30)) + TIMEZONE)%24; 
timeString[0] = hour/10 + 0x30 ;
timeString[1] = hour%10 + 0x30;
timeString[2] = ‘:‘;
timeString[3] = frameCache[9];
timeString[4] = frameCache[10];
timeString[5] = ‘:‘;
timeString[6] = frameCache[11];
timeString[7] = frameCache[12];
timeString[8] = ‘\0‘;
DisplayCgrom(0x88“时间:“);DisplayCgrom(0x8btimeString);
//DisplayCgrom(0x98“定位卫星: 8 颗“);//DisplayCgrom(0x9e‘8‘);
}

void getDate(void)
{
unsigned char dateString[11];
dateString[0] = frameCache[61];
dateString[1] = frameCache[62];
dateString[2] = ‘-‘;
dateString[3] = frameCache[59];
dateString[4] = frameCache[60];
dateString[5] = ‘-‘;
dateString[6] = frameCache[57];
dateString[7] = frameCache[58];
dateString[8] = ‘\0‘;
DisplayCgrom(0x90“日期:“);DisplayCgrom(0x93dateString);  

}

void getLatitude(void)
{
unsigned char LatitudeString[11];
LatitudeString[0] = frameCache[18];
LatitudeString[1] = frameCache[19];
LatitudeString[2] = frameCache[20];
LatitudeString[3] = frameCache[21];
LatitudeString[4] = frameCache[22];
LatitudeString[5] = frameCache[23];
LatitudeString[6] = frameCache[24];
LatitudeString[7] = frameCache[25];
LatitudeString[8] = frameCache[26];
LatitudeString[9] = frameCache[28];
LatitudeString[10] = ‘\0‘;
DisplayCgrom(0x88“经度:“);DisplayCgrom(0x8aLatitudeString);
}

void getLongitude(void)
{
unsigned char LongitudeString[12];
LongitudeString[0] = frameCache[30];
LongitudeString[1] = frameCache[31];
LongitudeString[2] = frameCache[32];
LongitudeString[3] = frameCache[33];
LongitudeString[4] = frameCache[34];
LongitudeString[5] = frameCache[35];
LongitudeString[6] = frameCache[36];
LongitudeString[7] = frameCache[37];
LongitudeString[8] = frameCache[38];
LongitudeString[9] = frameCache[39];
LongitudeString[10] = frameCache[41];
LongitudeString[11] = ‘\0‘;
DisplayCgrom(0x90“纬度:“);DisplayCgrom(0x92LongitudeString);
}

void getAltitude(void)
{
unsigned char AltitudeString[7];
AltitudeString[0] = frameCache[52];
AltitudeString[1] = frameCache[53];
AltitudeString[2] = frameCache[54];
AltitudeString[3] = frameCache[55];
AltitudeString[4] = frameCache[56];
AltitudeString[5] = ‘M‘;
AltitudeString[6] = ‘\0‘;
DisplayCgrom(0x98“高度:“);DisplayCgrom(0x9aAltitudeString);
}

void initSerialCom(void)
{    
SCON = 0x50 ; //SCON: serail mode 1 8-bit UART ena

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4865  2012-05-26 23:39  GPS_RECEIVE.SRC\Gpa.c

     文件      10610  2012-05-26 23:39  GPS_RECEIVE.SRC\Gpa.LST

     文件      18296  2012-05-26 23:39  GPS_RECEIVE.SRC\Gpa.OBJ

     文件      15706  2012-05-26 23:39  GPS_RECEIVE.SRC\Gps

     文件       3553  2012-05-26 23:39  GPS_RECEIVE.SRC\Gps.hex

     文件         54  2012-05-26 23:39  GPS_RECEIVE.SRC\Gps.lnp

     文件      21496  2012-05-26 23:39  GPS_RECEIVE.SRC\Gps.M51

     文件      33384  2012-05-26 23:40  GPS_RECEIVE.SRC\Gps.plg

    .......     56486  2012-05-26 23:40  GPS_RECEIVE.SRC\Gps.uvopt

    .......     13399  2012-05-26 21:07  GPS_RECEIVE.SRC\Gps.uvproj

    .......     56482  2012-05-26 21:07  GPS_RECEIVE.SRC\Gps_uvopt.bak

    .......     13398  2012-05-26 21:07  GPS_RECEIVE.SRC\Gps_uvproj.bak

     文件       5130  2012-05-25 03:32  GPS_RECEIVE.SRC\LCD12864.h

     文件       6376  2009-05-07 14:37  GPS_RECEIVE.SRC\STARTUP.A51

     文件      14048  2012-05-26 23:39  GPS_RECEIVE.SRC\STARTUP.LST

     文件        749  2012-05-26 23:39  GPS_RECEIVE.SRC\STARTUP.OBJ

     目录          0  2012-05-26 23:40  GPS_RECEIVE.SRC

----------- ---------  ---------- -----  ----

               274032                    17


评论

共有 条评论