久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 4660|回復(fù): 2
打印 上一主題 下一主題
收起左側(cè)

GPS的GPSMC數(shù)據(jù)包截獲程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:82781 發(fā)表于 2015-6-14 01:16 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
本程序是GPS的GPSMC數(shù)據(jù)包的截獲程序,沒(méi)有加入解算程序,只對(duì)GPS數(shù)據(jù)包進(jìn)行了截獲,通過(guò)實(shí)驗(yàn),數(shù)據(jù)包的截獲沒(méi)有錯(cuò)誤,以后再加入數(shù)據(jù)包解算程序就是小菜一碟哩,數(shù)據(jù)包存到內(nèi)存中,想什么時(shí)候解救什么時(shí)候接,爽,隨時(shí)可以更新數(shù)據(jù)包內(nèi)容,方便的控制,在程序中任意時(shí)間都可以進(jìn)行數(shù)據(jù)獲取!!!!
王均偉

與無(wú)錫第五項(xiàng)目部工棚!

uint8_t numb=0; /*解包算法變量*/
uint8_t wr_tab_start=0; /*這個(gè)變量尤其重要,當(dāng)他=0時(shí)是截獲GPS中的GPSMC包=1是截獲成功開(kāi)始把數(shù)據(jù)寫(xiě)入內(nèi)存,=2是數(shù)據(jù)接收完畢可以進(jìn)行其他操作*/
uint8_t tab[59];/*GPSMC數(shù)據(jù)包有效長(zhǎng)度*/
uint8_t counter=0; /*counter是數(shù)據(jù)計(jì)數(shù)器*/
void InitUART(void)
{
    TMOD = 0x20;
    SCON = 0x50;
    TH1 = 0xFA;
    TL1 = TH1;
    PCON = 0x00;
    EA = 1;
    ES = 1;
    TR1 = 1;
}
void UARTInterrupt(void) interrupt 4
{
   
    if(RI)
    {
        RI = 0;
    if(wr_tab_start==0)
    {
  switch (numb){
  
       case 0:if(SBUF==0x24){numb=1;P0=0;}else {numb=0;};break;
      case 1:if(SBUF==0x47){numb=2;P0=2;}else {numb=0;}break;
       case 2:if(SBUF==0x50){numb=3;P0=4;}else {numb=0;}break;
       case 3:if(SBUF==0x52){numb=4;P0=8;}else {numb=0;}break;
       case 4:if(SBUF==0x4D){numb=5;P0=0x20;}else {numb=0;}break;
      case 5:if(SBUF==0x43){numb=6;P0=0x40;}else {numb=0;}break;
      case 6:if(SBUF==0x2C){ counter=0;wr_tab_start=1;numb=0;P0=0x80;}break;

              }
      }
   else if(wr_tab_start==1)
   {
     P0=counter;
   
     tab[counter]=SBUF;
     counter++;
   
      
  if(counter==60)
                  {
                wr_tab_start=2;

                  }
        //add your code here!
              }
    else
        TI = 0;
}

}
void SendOneByte(unsigned char c)
{
    SBUF = c;
    while(!TI);
    TI = 0;
}
void main(void)
{
    uint8_t i;
InitUART();
while(1)
   {
   if(wr_tab_start==2)
   {
   
   
     for(i=0;i<60;i++)
   {
   
     SendOneByte(tab[i]);
   
   
   }
   /*此處可以進(jìn)行包處理,解包和數(shù)據(jù)的顯示
   令wr_tab_start=0;表示接收下一個(gè)包
   
   */
   
      wr_tab_start=3;
   
   }
   }
}



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:82781 發(fā)表于 2015-6-14 01:17 | 只看該作者
GPS接收數(shù)據(jù),坐標(biāo)在液晶顯示



  1. #include "main.h"
  2. #include "12864.h"

  3. uint8_t numb=0; /*解包算法變量*/
  4. uint8_t wr_tab_start=0; /*這個(gè)變量尤其重要,當(dāng)他=0時(shí)是截獲GPS中的GPSMC包=1是截獲成功開(kāi)始把數(shù)據(jù)寫(xiě)入內(nèi)存,=2是數(shù)據(jù)接收完畢可以進(jìn)行其他操作*/
  5. uint8_t tab[59];/*GPSMC數(shù)據(jù)包有效長(zhǎng)度*/
  6. uint8_t counter=0; /*counter是數(shù)據(jù)計(jì)數(shù)器*/

  7. void InitUART(void)
  8. {
  9.     TMOD = 0x20;
  10.     SCON = 0x50;
  11.     TH1 = 0xFA;
  12.     TL1 = TH1;
  13.     PCON = 0x00;
  14.     EA = 1;
  15.     ES = 1;
  16.     TR1 = 1;
  17. }
  18. void UARTInterrupt(void) interrupt 4
  19. {
  20.   
  21.     if(RI)
  22.     {
  23.         RI = 0;
  24.     if(wr_tab_start==0)
  25.     {
  26.   switch (numb){

  27.        case 0:if(SBUF==0x24){numb=1;P0=0;}else {numb=0;};break;
  28.       case 1:if(SBUF==0x47){numb=2;P0=2;}else {numb=0;}break;
  29.        case 2:if(SBUF==0x50){numb=3;P0=4;}else {numb=0;}break;
  30.        case 3:if(SBUF==0x52){numb=4;P0=8;}else {numb=0;}break;
  31.        case 4:if(SBUF==0x4D){numb=5;P0=0x20;}else {numb=0;}break;
  32.       case 5:if(SBUF==0x43){numb=6;P0=0x40;}else {numb=0;}break;
  33.       case 6:if(SBUF==0x2C){ counter=0;wr_tab_start=1;numb=0;P0=0x80;}break;


  34.               }

  35.       }
  36.    else if(wr_tab_start==1)
  37.    {

  38.      P0=counter;
  39.    
  40.      tab[counter]=SBUF;
  41.      counter++;
  42.    
  43.       
  44.   if(counter==60)
  45.                   {
  46.                 wr_tab_start=2;


  47.                   }
  48.         //add your code here!
  49.               }
  50.     else
  51.         TI = 0;
  52. }


  53. }

  54. void SendOneByte(unsigned char c)
  55. {
  56.     SBUF = c;
  57.     while(!TI);
  58.     TI = 0;
  59. }

  60. void main(void)
  61. {
  62.   
  63.   uint8_t i;

  64.       reset=0;
  65.     delay();
  66.     reset=1;   //復(fù)位12864
  67.     delay40ms();

  68.   writectrl(0x01);//DDRAM的AC計(jì)數(shù)器清零

  69.    delay4_6ms();


  70.    writectrl(0x02);//AC清零,游標(biāo)到開(kāi)頭為之

  71.   delay4_6ms();

  72.    writectrl(0x0f);//游標(biāo)開(kāi),整體顯示開(kāi),游標(biāo)位置開(kāi)

  73.   delay4_6ms();

  74.     writectrl((0x80));//寫(xiě)漢字顯示地址 DDRAM說(shuō)白了就是那個(gè)你在那里顯示這個(gè)漢子從第一行到第四行80H-9FH,一共32個(gè)漢子
  75.    delay4_6ms();   
  76.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  77.            //顯示J經(jīng)度
  78.   writedate(0xCA);  //數(shù)據(jù)寫(xiě)入FFH
  79.   delay4_6ms();

  80.   writectrl((0x81));// //寫(xiě)地址
  81.    delay4_6ms();

  82.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  83.              //顯示:
  84.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  85.   delay4_6ms();





  86.   writectrl((0x88));////寫(xiě)地址
  87.    delay4_6ms();
  88.   
  89.       
  90.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  91.   writedate(0xD7);  //數(shù)據(jù)寫(xiě)入FFH   //顯示W(wǎng)
  92.   delay4_6ms();


  93.   writectrl((0x89));////寫(xiě)地址
  94.    delay4_6ms();
  95.   
  96.       
  97.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  98.              //顯示:
  99.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  100.   delay4_6ms();



  101.   writectrl((0x90));////寫(xiě)地址
  102.    delay4_6ms();
  103.   
  104.       
  105.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  106.   writedate(0xD3);  //數(shù)據(jù)寫(xiě)入FFH   //顯示S
  107.   delay4_6ms();


  108.   writectrl((0x91));////寫(xiě)地址
  109.    delay4_6ms();
  110.   
  111.       
  112.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  113.              //顯示:
  114.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  115.   delay4_6ms();


  116.   writectrl((0x98));////寫(xiě)地址
  117.    delay4_6ms();
  118.   
  119.       
  120.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  121.   writedate(0xD4);  //數(shù)據(jù)寫(xiě)入FFH   //顯示T
  122.   delay4_6ms();


  123.   writectrl((0x99));////寫(xiě)地址
  124.    delay4_6ms();
  125.   
  126.       
  127.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  128.              //顯示:
  129.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  130.   delay4_6ms();
  131.    /////////////////以上是固定不變的////////////////////////////////////////////////
  132. /////////////////以上是固定不變的////////////////////////////////////////////////
  133. InitUART();
  134. ////////////////////以上是液晶設(shè)置,以下是顯示地址設(shè)置

  135.    


  136. while(1)
  137.    {
  138.    if(wr_tab_start==2)
  139.    {
  140.   
  141.      time->hou1=tab[0];
  142.      time->hou2=tab[1];
  143.      time->min1=tab[2];
  144.      time->min2=tab[3];
  145.      time->sec1=tab[4];
  146.      time->sec2=tab[5];


  147.    /*此處可以進(jìn)行包處理,解包和數(shù)據(jù)的顯示
  148.    令wr_tab_start=0;表示接收下一個(gè)包
  149.   
  150.    */
  151.    

  152.    EA=0;
  153.     //////////數(shù)據(jù)有效為/////////////////////////
  154.      writectrl((0x92));///寫(xiě)地址
  155.   delay4_6ms();

  156.   
  157.       
  158.   writedate(tab[11]);  //數(shù)據(jù)寫(xiě)入FFH
  159.     delay4_6ms();

  160. //////////////////////////////////////////


  161.     writectrl((0x82));///寫(xiě)地址
  162.   delay4_6ms();

  163.   
  164.       
  165.   writedate(tab[26]);  //數(shù)據(jù)寫(xiě)入FFH
  166.          
  167.   writedate(tab[27]);  //數(shù)據(jù)寫(xiě)入FFH
  168.     delay4_6ms();
  169.    writectrl((0x83));//寫(xiě)地址
  170.     delay4_6ms();

  171.       
  172.   writedate(tab[28]);  //數(shù)據(jù)寫(xiě)入FFH
  173.            //顯示:
  174.   writedate(tab[29]);  //數(shù)據(jù)寫(xiě)入FFH
  175.     delay4_6ms();
  176.    writectrl((0x84));///寫(xiě)地址
  177.     delay4_6ms();

  178.   
  179.       
  180.   writedate(tab[30]);  //數(shù)據(jù)寫(xiě)入FFH
  181.             //顯示: ,
  182.   writedate(tab[31]);  //數(shù)據(jù)寫(xiě)入FFH
  183.      delay4_6ms();
  184.    writectrl((0x85));///寫(xiě)地址
  185.    delay4_6ms();

  186.       
  187.   writedate(tab[32]);  //數(shù)據(jù)寫(xiě)入FFH
  188.           //顯示: ,
  189.   writedate(tab[33]);  //數(shù)據(jù)寫(xiě)入FFH
  190.   delay4_6ms();
  191.     writectrl((0x86));///寫(xiě)地址
  192.   delay4_6ms();

  193.       
  194.   writedate(tab[34]);  //數(shù)據(jù)寫(xiě)入FFH
  195.    delay4_6ms();         //顯示: ,
  196.   writedate(tab[35]);  //數(shù)據(jù)寫(xiě)入FFH
  197.     delay4_6ms();
  198.      writectrl((0x87));///寫(xiě)地址
  199.   delay4_6ms();

  200.       
  201.   writedate(tab[37]);  //數(shù)據(jù)寫(xiě)入FFH

  202.     delay4_6ms();

  203. /*以上是經(jīng)度顯示行,以下是緯度顯示行*/





  204.   
  205.     writectrl((0x8A));//寫(xiě)地址
  206.      delay4_6ms();
  207.       
  208.   writedate(tab[13]);  //數(shù)據(jù)寫(xiě)入FFH
  209.               //緯度的“度”
  210.   writedate(tab[14]);  //數(shù)據(jù)寫(xiě)入FFH
  211.   delay4_6ms();
  212.    writectrl((0x8B));////寫(xiě)地址
  213.   delay4_6ms();
  214.   writedate(tab[15]);  //數(shù)據(jù)寫(xiě)入FFH
  215.           //緯度的“分”
  216.   writedate(tab[16]);  //數(shù)據(jù)寫(xiě)入FFH
  217.   delay4_6ms();
  218.    writectrl((0x8C));////寫(xiě)地址
  219. delay4_6ms();
  220.       
  221.   writedate(tab[17]);  //數(shù)據(jù)寫(xiě)入FFH           //緯度的“秒”
  222.   writedate(tab[18]);  //數(shù)據(jù)寫(xiě)入FFH
  223.   delay4_6ms();
  224.     writectrl((0x8D));////寫(xiě)地址
  225.   delay4_6ms();
  226.       
  227.   writedate(tab[19]);  //數(shù)據(jù)寫(xiě)入FFH
  228.            //緯度的“分”
  229.   writedate(tab[20]);  //數(shù)據(jù)寫(xiě)入FFH
  230.     delay4_6ms();
  231.    writectrl((0x8E));////寫(xiě)地址
  232.    delay4_6ms();
  233.   
  234.       
  235.   writedate(tab[21]);  //數(shù)據(jù)寫(xiě)入FFH
  236.         //緯度的“秒”
  237.   writedate(tab[22]);  //數(shù)據(jù)寫(xiě)入FFH

  238.       delay4_6ms();
  239.        writectrl((0x8F));////寫(xiě)地址
  240.    delay4_6ms();
  241.   
  242.       
  243.   writedate(tab[24]);  //數(shù)據(jù)寫(xiě)入FFH

  244.       delay4_6ms();

  245.    /////////////////////////////////////////////////////
  246.    writectrl((0x9A));///寫(xiě)地址
  247.   delay4_6ms();

  248.   
  249.       
  250.   writedate(tab[0]);  //數(shù)據(jù)寫(xiě)入FFH
  251.          
  252.   writedate(tab[1]);  //數(shù)據(jù)寫(xiě)入FFH
  253.     delay4_6ms();
  254.    writectrl((0x9B));//寫(xiě)地址
  255.     delay4_6ms();

  256.       
  257.   writedate(tab[2]);  //數(shù)據(jù)寫(xiě)入FFH
  258.            //顯示:
  259.   writedate(tab[3]);  //數(shù)據(jù)寫(xiě)入FFH
  260.     delay4_6ms();
  261.    writectrl((0x9C));///寫(xiě)地址
  262.     delay4_6ms();

  263.   
  264.       
  265.   writedate(tab[4]);  //數(shù)據(jù)寫(xiě)入FFH
  266.             //顯示: ,
  267.   writedate(tab[5]);  //數(shù)據(jù)寫(xiě)入FFH
  268.      delay4_6ms();



  269.      EA=1;
  270.       wr_tab_start=0;
  271.   
  272.    }

  273.    }

  274. }

  275. 12864.c

  276. #include"12864.h"

  277. void delay40ms(void)   //誤差 -0.000000000009us
  278. {
  279.     unsigned char ad,bd,cd;
  280.     for(cd=11;cd>0;cd--)
  281.         for(bd=124;bd>0;bd--)
  282.             for(ad=12;ad>0;ad--);
  283. }
  284. void delay4_6ms()//
  285. {
  286. unsigned char av,bv;
  287.     for(bv=12;bv>0;bv--)
  288.         for(av=175;av>0;av--);

  289. }
  290. void delay(void)
  291. {
  292.      ;;;

  293. }

  294. void writedate(unsigned char a)//寫(xiě)數(shù)據(jù)
  295. {
  296.   





  297.    delay4_6ms();
  298.       rs=1;
  299.     delay();
  300.     rw=0;
  301.    delay();
  302.    e=1;
  303.    delay();


  304.    P0=a;
  305.   
  306.   

  307. delay();
  308. e=0;
  309. delay();






  310. }

  311. void writectrl(unsigned char ds)//寫(xiě)指令
  312. {
  313.   rs=0;
  314.    delay();
  315.     rw=0;
  316.   delay();
  317.    e=1;
  318.    delay();
  319. P0=ds;
  320. delay();
  321. e=0;
  322.    delay();
  323.   

  324. }
復(fù)制代碼
回復(fù)

使用道具 舉報(bào)

板凳
ID:82781 發(fā)表于 2015-6-14 01:17 | 只看該作者
GPS改進(jìn)后的程序,時(shí)差補(bǔ)償,搜索到衛(wèi)星報(bào)警
  1. #include "12864.h"
  2. #include"main.h"

  3. sbit reset=P1^5;
  4. sbit bell=P1^7;
  5. unsigned char numb=0; /*解包算法變量*/
  6. unsigned char wr_tab_start=0; /*這個(gè)變量尤其重要,當(dāng)他=0時(shí)是截獲GPS中的GPSMC包=1是截獲成功開(kāi)始把數(shù)據(jù)寫(xiě)入內(nèi)存,=2是數(shù)據(jù)接收完畢可以進(jìn)行其他操作*/
  7. unsigned char counter=0; /*counter是數(shù)據(jù)計(jì)數(shù)器*/
  8. unsigned char tab[59];/*GPSMC數(shù)據(jù)包有效長(zhǎng)度*/
  9. void InitUART(void)
  10. {
  11.     TMOD = 0x20;
  12.     SCON = 0x50;
  13.     TH1 = 0xFA;
  14.     TL1 = TH1;
  15.     PCON = 0x00;
  16.     EA = 1;
  17.     ES = 1;
  18.     TR1 = 1;
  19. }
  20. void UARTInterrupt(void) interrupt 4
  21. {
  22.   
  23.     if(RI)
  24.     {
  25.         RI = 0;
  26.     if(wr_tab_start==0)
  27.     {
  28.   switch (numb){

  29.        case 0:if(SBUF==0x24){numb=1;P0=0;}else {numb=0;};break;
  30.       case 1:if(SBUF==0x47){numb=2;P0=2;}else {numb=0;}break;
  31.        case 2:if(SBUF==0x50){numb=3;P0=4;}else {numb=0;}break;
  32.        case 3:if(SBUF==0x52){numb=4;P0=8;}else {numb=0;}break;
  33.        case 4:if(SBUF==0x4D){numb=5;P0=0x20;}else {numb=0;}break;
  34.       case 5:if(SBUF==0x43){numb=6;P0=0x40;}else {numb=0;}break;
  35.       case 6:if(SBUF==0x2C){ counter=0;wr_tab_start=1;numb=0;P0=0x80;}break;


  36.               }

  37.       }
  38.    else if(wr_tab_start==1)
  39.    {

  40.      P0=counter;
  41.    
  42.      tab[counter]=SBUF;
  43.      counter++;
  44.    
  45.       
  46.   if(counter==60)
  47.                   {
  48.                 wr_tab_start=2;


  49.                   }
  50.                       }
  51.     else
  52.         TI = 0;
  53. }


  54. }

  55. void SendOneByte(unsigned char c)
  56. {
  57.     SBUF = c;
  58.     while(!TI);
  59.     TI = 0;
  60. }

  61. void main(void)
  62. {
  63.   
  64.   unsigned char hour1,hour2,hour;


  65.    reset=0;
  66.     delay();
  67.     reset=1;   //復(fù)位12864
  68.     delay40ms();
  69.    init12864set();//進(jìn)行初始化液晶屏的固定的圖標(biāo)符號(hào)

  70. ////////////////////以上是液晶設(shè)置,以下是顯示地址設(shè)置

  71.    InitUART();


  72. while(1)
  73.    {
  74.    if(wr_tab_start==2)
  75.    {
  76.    


  77.    /*此處可以進(jìn)行包處理,解包和數(shù)據(jù)的顯示
  78.    令wr_tab_start=0;表示接收下一個(gè)包
  79.   
  80.    */
  81.    

  82.    EA=0;//開(kāi)中斷
  83.             _data_mode();//在液晶上顯示數(shù)據(jù)狀態(tài),A有效,V無(wú)效



  84.      switch (tab[1]){
  85.         /*各位把字符數(shù)據(jù)轉(zhuǎn)換10進(jìn)制*/
  86.        case 0x30:hour1=0;break;
  87.       case 0x31:hour1=1;break;
  88.        case 0x32:hour1=2;break;
  89.        case 0x33:hour1=3;break;
  90.        case 0x34:hour1=4;break;
  91.       case 0x35:hour1=5;break;
  92.       case 0x36:hour1=6;break;
  93.       case 0x37:hour1=7;break;
  94.       case 0x38:hour1=8;break;
  95.       case 0x39:hour1=9;break;
  96.       }

  97.    switch (tab[0]){
  98.         /*十位把字符數(shù)據(jù)轉(zhuǎn)換10進(jìn)制*/
  99.        case 0x30:hour2=0;break;
  100.       case 0x31:hour2=1;break;
  101.        case 0x32:hour2=2;break;
  102.       }
  103.       hour2=hour2*10;
  104.     hour=hour2+hour1;

  105.        switch (hour){
  106.         /*查表得出小時(shí)數(shù)*/
  107.        case 0 :tab[0]=0x30;tab[1]=0x38;break;
  108.       case 1 :tab[0]=0x30;tab[1]=0x39;break;
  109.        case 2 :tab[0]=0x31;tab[1]=0x30;break;
  110.       case 3 :tab[0]=0x31;tab[1]=0x31;break;
  111.       case 4 :tab[0]=0x31;tab[1]=0x32;break;
  112.        case 5 :tab[0]=0x31;tab[1]=0x33;break;
  113.       case 6 :tab[0]=0x31;tab[1]=0x34;break;
  114.       case 7 :tab[0]=0x31;tab[1]=0x35;break;
  115.        case 8 :tab[0]=0x31;tab[1]=0x36;break;
  116.       case 9 :tab[0]=0x31;tab[1]=0x37;break;
  117.       case 10:tab[0]=0x31;tab[1]=0x38;break;
  118.        case 11:tab[0]=0x31;tab[1]=0x39;break;
  119.       case 12:tab[0]=0x32;tab[1]=0x30;break;
  120.       case 13:tab[0]=0x32;tab[1]=0x31;break;
  121.        case 14:tab[0]=0x32;tab[1]=0x32;break;
  122.       case 15:tab[0]=0x32;tab[1]=0x33;break;
  123.       case 16:tab[0]=0x30;tab[1]=0x30;break;
  124.        case 17:tab[0]=0x30;tab[1]=0x31;break;
  125.       case 18:tab[0]=0x30;tab[1]=0x32;break;
  126.       case 19:tab[0]=0x30;tab[1]=0x33;break;
  127.        case 20:tab[0]=0x30;tab[1]=0x34;break;
  128.       case 21:tab[0]=0x30;tab[1]=0x35;break;
  129.       case 22:tab[0]=0x30;tab[1]=0x36;break;
  130.        case 23:tab[0]=0x30;tab[1]=0x37;break;

  131.       }

  132.      writectrl((0x9A));///寫(xiě)地址
  133.   delay4_6ms();

  134.       
  135.   writedate(tab[0]);  //數(shù)據(jù)寫(xiě)入FFH
  136.              //小時(shí)顯示
  137.   writedate(tab[1]);  //數(shù)據(jù)寫(xiě)入FFH


  138.     delay4_6ms();
  139.    writectrl((0x9B));//寫(xiě)地址
  140.     delay4_6ms();

  141.       
  142.   writedate(tab[2]);  //數(shù)據(jù)寫(xiě)入FFH
  143.            //分鐘顯示:
  144.   writedate(tab[3]);  //數(shù)據(jù)寫(xiě)入FFH
  145.     delay4_6ms();
  146.    writectrl((0x9C));///寫(xiě)地址
  147.     delay4_6ms();

  148.   
  149.       
  150.   writedate(tab[4]);  //數(shù)據(jù)寫(xiě)入FFH
  151.             //秒顯示: ,
  152.   writedate(tab[5]);  //數(shù)據(jù)寫(xiě)入FFH
  153.      delay4_6ms();


  154.    if(0x41==tab[11])//如果衛(wèi)星數(shù)據(jù)有效則進(jìn)行寫(xiě)液晶的經(jīng)緯度坐標(biāo)
  155.    {
  156. //////////////////////////////////////////

  157.       bell=0;
  158.      delay40ms();  //蜂鳴器
  159.      delay40ms();
  160.      bell=1;


  161.    longitude_display();//經(jīng)度顯示

  162. /*以上是經(jīng)度顯示行,以下是緯度顯示行*/

  163.         latitude_display();//緯度顯示

  164.    ////////////////////////////////////////////////////
  165.      }


  166.      EA=1;//開(kāi)中斷
  167.       wr_tab_start=0;


  168.    }

  169.    }

  170. }



  171. void init12864set()
  172. {


  173.      

  174.   writectrl(0x01);//DDRAM的AC計(jì)數(shù)器清零

  175.    delay4_6ms();


  176.    writectrl(0x02);//AC清零,游標(biāo)到開(kāi)頭為之

  177.   delay4_6ms();

  178.    writectrl(0x0C);//整體顯示開(kāi)

  179.   delay4_6ms();

  180.     writectrl((0x80));//寫(xiě)漢字顯示地址 DDRAM說(shuō)白了就是那個(gè)你在那里顯示這個(gè)漢子從第一行到第四行80H-9FH,一共32個(gè)漢子
  181.    delay4_6ms();   
  182.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  183.            //顯示J經(jīng)度
  184.   writedate(0xCA);  //數(shù)據(jù)寫(xiě)入FFH
  185.   delay4_6ms();

  186.   writectrl((0x81));// //寫(xiě)地址
  187.    delay4_6ms();

  188.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  189.              //顯示:
  190.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  191.   delay4_6ms();





  192.   writectrl((0x88));////寫(xiě)地址
  193.    delay4_6ms();
  194.   
  195.       
  196.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  197.   writedate(0xD7);  //數(shù)據(jù)寫(xiě)入FFH   //顯示W(wǎng)
  198.   delay4_6ms();


  199.   writectrl((0x89));////寫(xiě)地址
  200.    delay4_6ms();
  201.   
  202.       
  203.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  204.              //顯示:
  205.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  206.   delay4_6ms();



  207.   writectrl((0x90));////寫(xiě)地址
  208.    delay4_6ms();
  209.   
  210.       
  211.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  212.   writedate(0xD3);  //數(shù)據(jù)寫(xiě)入FFH   //顯示S
  213.   delay4_6ms();


  214.   writectrl((0x91));////寫(xiě)地址
  215.    delay4_6ms();
  216.   
  217.       
  218.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  219.              //顯示:
  220.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  221.   delay4_6ms();


  222.   writectrl((0x98));////寫(xiě)地址
  223.    delay4_6ms();
  224.   
  225.       
  226.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH

  227.   writedate(0xD4);  //數(shù)據(jù)寫(xiě)入FFH   //顯示T
  228.   delay4_6ms();


  229.   writectrl((0x99));////寫(xiě)地址
  230.    delay4_6ms();
  231.   
  232.       
  233.   writedate(0xA3);  //數(shù)據(jù)寫(xiě)入FFH
  234.              //顯示:
  235.   writedate(0xBA);  //數(shù)據(jù)寫(xiě)入FFH
  236.   delay4_6ms();
  237.    /////////////////以上是固定不變的////////////////////////////////////////////////
  238. /////////////////以上是固定不變的////////////////////////////////////////////////


  239. }
  240. /*數(shù)據(jù)標(biāo)志位,A表示數(shù)據(jù)有效V表示數(shù)據(jù)無(wú)效*/
  241. void   _data_mode()
  242. {




  243.     //////////數(shù)據(jù)有效為/////////////////////////
  244.      writectrl((0x92));///寫(xiě)地址
  245.   delay4_6ms();

  246.   
  247.       
  248.   writedate(tab[11]);  //數(shù)據(jù)寫(xiě)入FFH
  249.     delay4_6ms();


  250. }
  251. /*經(jīng)度顯示*/
  252. void longitude_display()
  253. {

  254. writectrl((0x82));///寫(xiě)地址
  255.   delay4_6ms();

  256.   
  257.       
  258.   writedate(tab[25]);  //數(shù)據(jù)寫(xiě)入FFH
  259.          
  260.   writedate(tab[26]);  //數(shù)據(jù)寫(xiě)入FFH
  261.     delay4_6ms();
  262.    writectrl((0x83));//寫(xiě)地址
  263.     delay4_6ms();
  264.                //j經(jīng)度
  265.       
  266.   writedate(tab[27]);  //數(shù)據(jù)寫(xiě)入FFH
  267.            //顯示:
  268.   writedate(tab[28]);  //數(shù)據(jù)寫(xiě)入FFH
  269.     delay4_6ms();
  270.    writectrl((0x84));///寫(xiě)地址
  271.     delay4_6ms();

  272.   
  273.       
  274.   writedate(tab[29]);  //數(shù)據(jù)寫(xiě)入FFH
  275.             //顯示: ,
  276.   writedate(tab[30]);  //數(shù)據(jù)寫(xiě)入FFH
  277.      delay4_6ms();
  278.    writectrl((0x85));///寫(xiě)地址
  279.    delay4_6ms();

  280.       
  281.   writedate(tab[31]);  //數(shù)據(jù)寫(xiě)入FFH
  282.           //顯示: ,
  283.   writedate(tab[32]);  //數(shù)據(jù)寫(xiě)入FFH        //經(jīng)度
  284.   delay4_6ms();
  285.     writectrl((0x86));///寫(xiě)地址
  286.   delay4_6ms();

  287.       
  288.   writedate(tab[33]);  //數(shù)據(jù)寫(xiě)入FFH
  289.    delay4_6ms();         //顯示: ,
  290.   writedate(tab[34]);  //數(shù)據(jù)寫(xiě)入FFH
  291.     delay4_6ms();
  292.      writectrl((0x87));///寫(xiě)地址
  293.   delay4_6ms();

  294.       
  295.   writedate(tab[35]);  //數(shù)據(jù)寫(xiě)入FFH
  296.   writedate(tab[36]);  //數(shù)據(jù)寫(xiě)入FFH
  297.     delay4_6ms();
  298. }

  299. /*緯度在液晶上的顯示*/
  300. void latitude_display()
  301. {



  302.   
  303.     writectrl((0x8A));//寫(xiě)地址
  304.      delay4_6ms();
  305.       
  306.   writedate(tab[13]);  //數(shù)據(jù)寫(xiě)入FFH
  307.               //緯度的“度”
  308.   writedate(tab[14]);  //數(shù)據(jù)寫(xiě)入FFH
  309.   delay4_6ms();               //緯度
  310.    writectrl((0x8B));////寫(xiě)地址
  311.   delay4_6ms();
  312.   writedate(tab[15]);  //數(shù)據(jù)寫(xiě)入FFH
  313.           //緯度的“分”
  314.   writedate(tab[16]);  //數(shù)據(jù)寫(xiě)入FFH
  315.   delay4_6ms();
  316.    writectrl((0x8C));////寫(xiě)地址
  317. delay4_6ms();
  318.       
  319.   writedate(tab[17]);  //數(shù)據(jù)寫(xiě)入FFH           //緯度的“秒”
  320.   writedate(tab[18]);  //數(shù)據(jù)寫(xiě)入FFH
  321.   delay4_6ms();
  322.     writectrl((0x8D));////寫(xiě)地址
  323.   delay4_6ms();
  324.       
  325.   writedate(tab[19]);  //數(shù)據(jù)寫(xiě)入FFH
  326.            //緯度的“分”
  327.   writedate(tab[20]);  //數(shù)據(jù)寫(xiě)入FFH
  328.     delay4_6ms();
  329.    writectrl((0x8E));////寫(xiě)地址
  330.    delay4_6ms();
  331.   
  332.       
  333.   writedate(tab[21]);  //數(shù)據(jù)寫(xiě)入FFH
  334.         //緯度的“秒”             //緯度
  335.   writedate(tab[22]);  //數(shù)據(jù)寫(xiě)入FFH

  336.       delay4_6ms();
  337.        writectrl((0x8F));////寫(xiě)地址
  338.    delay4_6ms();
  339.   
  340.    writedate(tab[23]);  //數(shù)據(jù)寫(xiě)入FFH   
  341.   writedate(tab[24]);  //數(shù)據(jù)寫(xiě)入FFH

  342.       delay4_6ms();
  343. }


  344. 12864.c

  345. #include"12864.h"

  346. void delay40ms(void)   //誤差 -0.000000000009us
  347. {
  348.     unsigned char ad,bd,cd;
  349.     for(cd=11;cd>0;cd--)
  350.         for(bd=124;bd>0;bd--)
  351.             for(ad=12;ad>0;ad--);
  352. }
  353. void delay4_6ms()//
  354. {
  355. unsigned char av,bv;
  356.     for(bv=12;bv>0;bv--)
  357.         for(av=175;av>0;av--);

  358. }
  359. void delay(void)
  360. {
  361.      ;;;

  362. }

  363. void writedate(unsigned char a)//寫(xiě)數(shù)據(jù)
  364. {
  365.   





  366.    delay4_6ms();
  367.       rs=1;
  368.     delay();
  369.     rw=0;
  370.    delay();
  371.    e=1;
  372.    delay();


  373.    P0=a;
  374.   
  375.   

  376. delay();
  377. e=0;
  378. delay();






  379. }

  380. void writectrl(unsigned char ds)//寫(xiě)指令
  381. {
  382.   rs=0;
  383.    delay();
  384.     rw=0;
  385.   delay();
  386.    e=1;
  387.    delay();
  388. P0=ds;
  389. delay();
  390. e=0;
  391.    delay();
  392.   

  393. }
復(fù)制代碼
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 久久久久国产一区二区 | 国产精品久久久久一区二区三区 | 国产精品久久久久久久久久久久久 | 日韩毛片免费看 | 丁香综合 | 亚洲精品白浆高清久久久久久 | 精品99在线 | 午夜av在线 | 亚洲午夜在线 | 国产精品日日摸夜夜添夜夜av | 国产成人精品一区二三区在线观看 | 一二三在线视频 | 在线国产一区二区三区 | 国产美女特级嫩嫩嫩bbb片 | 久久久久无码国产精品一区 | 精品日本中文字幕 | 中国三级黄色录像 | 日韩精品亚洲专区在线观看 | 中文在线日韩 | 欧美一级特黄aaa大片在线观看 | 99精品视频在线观看 | 99久久婷婷国产综合精品电影 | 91精品国产91久久久久久密臀 | 亚洲精品第一页 | 日韩欧美精品在线播放 | 日韩一区二区黄色片 | 久久久网 | 国产成人午夜高潮毛片 | 午夜丰满少妇一级毛片 | 久久精品日产第一区二区三区 | 久久不卡 | 精品综合在线 | 久久久免费 | 亚洲第一色av | 国产精品一区二区三区99 | 在线看免费的a | 亚洲狠狠爱一区二区三区 | 九九色综合| 色橹橹欧美在线观看视频高清 | 亚洲最大av| av一区二区三区四区 |