ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:77.30KB ,
资源ID:11484570      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/11484570.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(51单片机解析GPS最新程序.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

51单片机解析GPS最新程序.docx

1、51单片机解析GPS最新程序51单片机解析GPS最新程序D LCD1602_RS=0; LCD1602_RW=0; LCD1602_EN=0; switch(BitWidth) case 4: LCDIO=(command & 0xf0); /取高4位 break; case 8: LCDIO=command; break; SET_LCD(LCDIO); LCD1602_EN=1; lcddelay(); LCD1602_EN=0; if (BitWidth=4) LCDIO=(command & 0x0f)4; /取低4位 SET_LCD(LCDIO); LCD1602_EN=1; lcd

2、delay(); LCD1602_EN=0; void SET_LCD(unsigned char IO_temp) /高4位 LCD_DB7=IO_temp&0x80; LCD_DB6=IO_temp&0x40; LCD_DB5=IO_temp&0x20; LCD_DB4=IO_temp&0x10; /低4位 if (BitWidth=8) LCD_DB3=IO_temp&0x08; LCD_DB2=IO_temp&0x04; LCD_DB1=IO_temp&0x02; LCD_DB0=IO_temp&0x01; void LCD_en_dat(unsigned char dat) LCD1

3、602_RS=1; LCD1602_RW=0; LCD1602_EN=0; switch(BitWidth) case 4: LCDIO=(dat & 0xf0); /取高4位 break; case 8: LCDIO=dat; break; SET_LCD(LCDIO); LCD1602_EN=1; lcddelay(); LCD1602_EN=0; if (BitWidth=4) LCDIO=(dat & 0x0f)4; /取低4位 SET_LCD(LCDIO); LCD1602_EN=1; lcddelay(); LCD1602_EN=0; /*=*1602* 输入参数:x、y : 显示

4、字符串的坐标,X:0-15,Y:0-1*LCD第一行显示寄存器地址:0X80-0X8F*LCD第二行显示寄存器地址:0XC0-0XCF *2404*LCD第1行显示地址:120(0x800x93) *LCD第2行显示地址:120(0xc00xd3) *LCD第3行显示地址:120(0x940xa7) *LCD第4行显示地址:120(0xd40xe7) =*/ void LCD_set_xy( unsigned char x, unsigned char y ) unsigned char address; if (y =0) address = 0x80 + x; else if(y=1) a

5、ddress = 0xC0 + x; else if(y=2) address = 0x94 + x; else if(y=3) address = 0xD4 + x; LCD_en_command(address); void LCD_write_char( unsigned x,unsigned char y,unsigned char dat) LCD_set_xy( x, y ); LCD_en_dat(dat);void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s) LCD_set_xy( X,

6、Y ); /set address while (*s) / write character LCDIO=*s; SET_LCD(LCDIO); LCD_en_dat(*s); s +; void LCD_init(unsigned char bw) BitWidth=bw; switch(BitWidth) case 4: LCD_en_command(0x33); / delayms(20); LCD_en_command(0x32); / delayms(20); break; case 8: LCD_en_command(0x38); / delayms(20); LCD_en_com

7、mand(0x38); / delayms(20); break; LCD_en_command(0x08); /0x08 令显示器off delayms(5); LCD_en_command(0x01); /0x01 清屏 清屏指令 delayms(5); LCD_en_command(0x06); /0x06 光标模式设置 进入模式设置指令 写入数据后光标右移 delayms(5); LCD_en_command(0x0c); /0x0c 显示开 令光标,0x0c=不显示,0x0d=显示闪动 delayms(5);void delayms(unsigned char ms) unsigne

8、d char i; while(ms-) for(i = 0; i 115; i+); void lcddelay(void) unsigned char i; for(i = 0; i 2; i+);/* GPS解码显示程序,*/#include#include 1602.h/#includemath.h/#include sbit GPS_SPD=P32; /GPS模块速率设置sbit KEY1=P33; /显示内容分屏切换,(T0,T1引脚 的第二功能为计数器。)char code TIME_AREA= 8; /时区/* 这是做的部分更改*/unsigned long maxspeed,

9、b;unsigned int count=0;unsigned int a5;unsigned char hspeed5;unsigned int dot_count; /小数点计数器/unsigned char x;/GPS数据存储数组unsigned char JD10; /经度unsigned char JD_a; /经度方向unsigned char WD9; /纬度unsigned char WD_a; /纬度方向unsigned char date6; /日期unsigned char time6; /时间unsigned char speed5=0,0,0,.,0; /速度uns

10、igned char high6; /高度unsigned char angle5=0,0,0,0,0; /方位角unsigned char use_sat2; /使用的卫星数unsigned char total_sat2; /天空中总卫星数unsigned char lock; /定位状态/串口中断需要的变量unsigned char seg_count; /逗号计数器unsigned char byte_count; /位数计数器unsigned char cmd_number; /命令类型unsigned char mode; /0:结束模式,1:命令模式,2:数据模式unsigned

11、 char buf_full; /1:整句接收完成,相应数据有效。0:缓存数据无效。unsigned char cmd5; /命令类型存储数组/显示需要的变量unsigned int dsp_count; /刷新次数计数器/unsigned char time_count;bit page;void sys_init(void);bit chk_key(void);main() unsigned char i; char Bhour; sys_init(); lock=1; use_sat0=0; use_sat1=0; total_sat0=0; total_sat1=0; while(1)

12、 if(buf_full=0) /无GPS信号时 dsp_count+; if(dsp_count=65000) LCD_cls(); /清屏 LCD_write_string(0,0,No GPS connect.); LCD_write_string(0,1,Please Check.); while(buf_full=0); LCD_cls(); dsp_count=0; else /有GPS信号时 if(chk_key() /检测到按键切换显示 page=!page; LCD_cls(); if(!page) /页面1 if(buf_full|0x01) /GGA语句 if(lock=

13、0) /如果未定位 LCD_write_string(0,0,*-.-.- ); LCD_write_string(0,1,* -.-.- ); else /如果已定位 LCD_write_char(0,0,JD_a); /显示经度 for(i=0;i3;i+) LCD_write_char(i+1,0,JDi); LCD_write_char(4,0,.); for(i=3;i10;i+) LCD_write_char(i+2,0,JDi); LCD_write_char(0,1,WD_a); /显示纬度 LCD_write_char(1,1, ); for(i=0;i2;i+) LCD_w

14、rite_char(i+2,1,WDi); LCD_write_char(4,1,.); for(i=2;i9;i+) LCD_write_char(i+3,1,WDi); LCD_write_char(14,1,use_sat0); /显示接收卫星数 LCD_write_char(15,1,use_sat1); buf_full&=0x01; dsp_count=0; if(buf_full|0x02) /GSV语句 LCD_write_char(14,1,total_sat0); LCD_write_char(15,1,total_sat1); buf_full&=0x02; dsp_co

15、unt=0; if(buf_full|0x04) if(lock=0) /如果未定位 LCD_write_string(0,0,*-.-.- ); LCD_write_string(0,1,* -.-.- ); else /如果已定位 LCD_write_char(0,0,JD_a); /显示经度 for(i=0;i3;i+) LCD_write_char(i+1,0,JDi); LCD_write_char(4,0,.); for(i=3;i10;i+) LCD_write_char(i+2,0,JDi); LCD_write_char(0,1,WD_a); /显示纬度 LCD_write_

16、char(1,1, ); for(i=0;i2;i+) LCD_write_char(i+2,1,WDi); LCD_write_char(4,1,.); for(i=2;i=24) Bhour-=24; else if(Bhour0) Bhour+=24; LCD_write_char(0,1,date4); LCD_write_char(1,1,date5); LCD_write_char(2,1,date2); LCD_write_char(3,1,date3); LCD_write_char(4,1,date0); LCD_write_char(5,1,date1); LCD_writ

17、e_char(8,1,Bhour/10+0x30); LCD_write_char(9,1,Bhour%10+0x30); LCD_write_char(10,1,:); LCD_write_char(11,1,time2); LCD_write_char(12,1,time3); LCD_write_char(13,1,:); LCD_write_char(14,1,time4); LCD_write_char(15,1,time5); LCD_write_string(5,0,knot A); /在此处做的更改 if(lock=0) /如果未定位 LCD_write_string(0,0,

18、-.-); LCD_write_string(11,0,-.-); else /已经定位,在此处做的改动。/*/* 最大速度处理*/ dot_count=0; b=0; for(i=0;imaxspeed) maxspeed=b; /* 最大速度处理*/ if(count10) for(i=0;i15) count=0; hspeed0=maxspeed/1000+0x30; /把小数转成字符数组 hspeed1=(maxspeed/100)%10+0x30; hspeed2=(maxspeed/10)%10+0x30; hspeed3=.; hspeed4= maxspeed%10+0x30

19、; count+; LCD_write_string(5,0,Km/h A); LCD_write_char(0,0,hspeed0); LCD_write_char(1,0,hspeed1); LCD_write_char(2,0,hspeed2); LCD_write_char(3,0,hspeed3); LCD_write_char(4,0,hspeed4); /最大速度显 */ /*/ for(i=0;i5;i+) LCD_write_char(11+i,0,anglei); buf_full&=0x04; dsp_count=0; bit chk_key(void) if(!KEY1

20、) delayms(10); if(!KEY1) while(!KEY1); delayms(10); return(1); LCD_cls(); /清屏 return(0);/系统初始化void sys_init() unsigned char i; SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD = 0x21; /* TMOD: timer 1, mode 2, 8-bit reload */ if(GPS_SPD) TH1 = 0xfa; /* TH1: reload value for 9600 baud 11.059MHz */ else TH1 = 0xfd; /* TH1: reload value for 4800 baud 11.059MHz */ TR1 = 1; /* TR1: timer 1 run */ LCD_init(8); /初始化LCD LCD_write_string(0,0, GPS SIRF II 2 ); LCD_write_string(0,1, 11-11-23 1342 ); for(i=1;i4;i+) delayms(250); /LCD_cls(); IE=0x90; /开总中断、串口中断/串口接收中断void u

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1