⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f334.lst

📁 使用单片机C8050F330对无线发射接受模块进行配置与控制,使组件成为一个无线通讯中的基站.
💻 LST
📖 第 1 页 / 共 5 页
字号:
 545          {
 546   1         ADC0CN = 0x40;                      // ADC0 disabled; LP tracking
 547   1                                             // mode; ADC0 conversions are initiated 
 548   1                                             // on a write to ADBusy
 549   1         AMX0P  = 0x0a;                      // Temp sensor selected at + input
 550   1         AMX0N  = 0x11;                      // Single-ended mode
C51 COMPILER V8.02   F334                                                                  07/13/2006 10:09:54 PAGE 10  

 551   1      
 552   1         ADC0CF = (SYSCLK/3000000) << 3;     // ADC conversion clock <= 3MHz   
 553   1      
 554   1         ADC0CF &= ~0x04;                    // Make ADC0 right-justified
 555   1         REF0CN = 0x0E;                      // enable temp sensor, VREF = VDD, bias
 556   1                                             // generator is on.
 557   1      
 558   1         //EIE1 |=  0x08;                      // Enable ADC0 interrupt
 559   1         ADC0CN = 0x80;
 560   1         AD0BUSY = 1;
 561   1      }
 562          
 563          
 564          void Timer3_ISR (void) interrupt 14   //2.5ms
 565          {
 566   1         TMR3CN &= ~0x80;   
 567   1         key_scan_time++;  
 568   1      
 569   1         count_time++;
 570   1      
 571   1         key_press_time++;
 572   1      
 573   1         if (LcdBackLight_Delay_AfterS2410>0) LcdBackLight_Delay_AfterS2410--;
 574   1         else if (key_zt==99)
 575   1         {
 576   2           LcdBackLight_Delay_AfterS2410=0;
 577   2           BG_EN=0;
 578   2         }
 579   1      
 580   1         if ((key_press_time>400) && (key_zt==99))
 581   1         {
 582   2            BG_EN=1;
 583   2                S2410_PWR=1;
 584   2                key_press_time=0;
 585   2                key_zt=0;
 586   2         }
 587   1      
 588   1      
 589   1         if (key_time>0) key_time--;else key_time=0;
 590   1                           
 591   1         test++;
 592   1      
 593   1         if (GPS_Alarm_js>0) GPS_Alarm_js--;else GPS_Alarm_js=0;
 594   1      
 595   1         if (GPS_time>0) GPS_time--;else GPS_time=0;
 596   1      
 597   1         if (FM_delay>0) FM_delay--;else FM_delay=0;
 598   1      
 599   1      }
 600          
 601          void Measure (void)
 602          {
 603   1        // (X*5-Y)/25=Z    X:采样数字   Y:基准(mV)  Z:角度
 604   1         AMX0P  = 0x0a;
 605   1         AMX0N  = 0x11;
 606   1         AD0INT = 0;
 607   1         AD0BUSY = 1;
 608   1         while (!AD0INT);                 // Wait for conversion to complete
 609   1         AD0INT = 0;                      // Clear end-of-conversion indicator
 610   1         TL_Adresult=ADC0;                    // Store latest ADC conversion          
 611   1         
 612   1         AMX0P  = 0x00;
C51 COMPILER V8.02   F334                                                                  07/13/2006 10:09:54 PAGE 11  

 613   1         AMX0N  = 0x11;
 614   1         AD0INT = 0;
 615   1         AD0BUSY = 1;
 616   1         while (!AD0INT);                 // Wait for conversion to complete
 617   1         AD0INT = 0;                      // Clear end-of-conversion indicator
 618   1         GPS_Current=ADC0;                    // Store latest ADC conversion 
 619   1      }
 620          
 621          //-----------------------------------------------------------------------------
 622          //  ???3???
 623          //-----------------------------------------------------------------------------
 624          void Timer3_Init ()
 625          {
 626   1         TMR3CN = 0x00;                                     
 627   1         CKCON |= 0x40;   
 628   1         TMR3RL  = -60000;               
 629   1         TMR3    = TMR3RL;                  
 630   1         EIE1 |= 0x80;                      
 631   1         TMR3CN |= 0x04;                
 632   1      
 633   1      }
 634          
 635          
 636          //-----------------------------------------------------------------------------
 637          // 数模转换初始化
 638          //-----------------------------------------------------------------------------
 639          void DA_Init (void)
 640          {
 641   1         IDA0CN = 0xb2;       //D/A允许,定时器3溢出触发,1mA满度电流输出
 642   1         REF0CN = 0x0E;       //使用内部电压基准           
 643   1      }
 644          
 645          
 646          /*****************************************
 647          *      Uart Interrupt
 648          *
 649          *****************************************/
 650          void Rcv_INT(void) interrupt 4
 651          {
 652   1        unsigned char tmp;
 653   1        RI0=0;
 654   1        tmp=RecvByte;
 655   1        UartBuff=SBUF0;
 656   1        RecvByte++;  
 657   1        if (RecvByte<HeaderLength+1)
 658   1        {
 659   2          Header[tmp]=UartBuff;
 660   2        }
 661   1        if(RecvByte==HeaderLength)
 662   1        {
 663   2          if((Header[0]=='$')&&(Header[1]=='G')&&(Header[2]=='P')&&(Header[3]=='G')&&(Header[4]=='G')&&(Header[5
             -]=='A'))   
 664   2          {                  //if it is a "$GPGGA" frame
 665   3            FrameLength=1;
 666   3          }
 667   2              else  if((Header[0]=='$')&&(Header[1]=='G')&&(Header[2]=='P')&&(Header[3]=='R')&&(Header[4]=='M')&&(Heade
             -r[5]=='C'))   
 668   2          {                  //if it is a "$GPGGA" frame
 669   3            FrameLength=3;
 670   3          }
 671   2          else 
 672   2         { 
C51 COMPILER V8.02   F334                                                                  07/13/2006 10:09:54 PAGE 12  

 673   3            FrameLength=2;                //if it is other frame,discard it
 674   3          }                              
 675   2      
 676   2         }
 677   1      
 678   1          if(FrameLength==2)                   //deal with other frame
 679   1          {
 680   2            if(UartBuff==0x0D) CRByte=UartBuff;               //received CR
 681   2      
 682   2            if(UartBuff==0x0A) LFByte=UartBuff;           //received LF
 683   2      
 684   2            if(CRByte&&LFByte)             //received CR and LF,end of frame
 685   2            {
 686   3              RecvByte=0;              //clear byte counter
 687   3              FrameLength=0;           //clear frame length
 688   3              CRByte=0;                //clear CR byte
 689   3              LFByte=0;                //clear LF byte
 690   3              
 691   3              for (ii=0;ii<9;ii++)         // Longitude
 692   3              {
 693   4                 Longitude[ii]=0x30;
 694   4              }
 695   3              for (ii=0;ii<10;ii++)        // Latitude
 696   3              {
 697   4                Latitude[ii]=0x30;
 698   4              }
 699   3          
 700   3              DGPS=0x30;
 701   3      
 702   3              for (ii=0;ii<4;ii++)         // HDOP
 703   3              {
 704   4                HDOP[ii]=0x30;
 705   4              }                       
 706   3                  //IsGpsFrame=1;
 707   3              //gps_ok=99;
 708   3            }
 709   2          }
 710   1      
 711   1         if(FrameLength==1)                      //deal with the "$GPGGA" frame
 712   1          {
 713   2            if((RecvByte>7)&&(RecvByte<18)) UTCtime[tmp-7]=UartBuff;     //received UTCtime
 714   2      
 715   2            if((RecvByte==20)&&(UartBuff==','))  FrameLength=2;//????,???????,???????
 716   2            if((RecvByte>18)&&(RecvByte<28)) Longitude[tmp-18]=UartBuff; //received jing du
 717   2      
 718   2            if((RecvByte>30)&&(RecvByte<41)) Latitude[tmp-30]=UartBuff;  //received wei du
 719   2      
 720   2            if (RecvByte==44) DGPS=UartBuff;
 721   2            
 722   2            if((RecvByte>45)&&(RecvByte<48)) weixing[tmp-45]=UartBuff;  //received weixing ge shu
 723   2            
 724   2            else if ((RecvByte>48)&&(RecvByte<53)&&(UartBuff!=',')) 
 725   2            {
 726   3              HDOP[tmp-48]=UartBuff; 
 727   3            }
 728   2            
 729   2            if(RecvByte>60)  //52
 730   2            {
 731   3              if(UartBuff==0x0D) CRByte=UartBuff;          //received CR
 732   3      
 733   3              if(UartBuff==0x0A) LFByte=UartBuff;           //receive
 734   3      
C51 COMPILER V8.02   F334                                                                  07/13/2006 10:09:54 PAGE 13  

 735   3              if(CRByte&&LFByte)             //received CR and LF,end of frame
 736   3              {
 737   4                RecvByte=0;              //clear byte counter
 738   4                FrameLength=0;           //clear frame length
 739   4                CRByte=0;                //clear CR byte
 740   4                LFByte=0;                //clear LF byte
 741   4                IsGpsFrame=1;
 742   4                gps_ok=99;
 743   4              }
 744   3            }
 745   2          }
 746   1      
 747   1         if(FrameLength==3)                      //deal with the "$GPGGA" frame
 748   1          {
 749   2            if((RecvByte>55)&&(RecvByte<62)) riqi[tmp-55]=UartBuff;     //received Data
 750   2      
 751   2            if(RecvByte>62)  //52
 752   2            {
 753   3              if(UartBuff==0x0D) CRByte=UartBuff;          //received CR
 754   3      
 755   3              if(UartBuff==0x0A) LFByte=UartBuff;           //receive
 756   3      
 757   3              if(CRByte&&LFByte)             //received CR and LF,end of frame
 758   3              {
 759   4                RecvByte=0;              //clear byte counter
 760   4                FrameLength=0;           //clear frame length
 761   4                CRByte=0;                //clear CR byte
 762   4                LFByte=0;                //clear LF byte
 763   4                //IsGpsFrame=1;
 764   4                //gps_ok=99;
 765   4              }
 766   3            }
 767   2          }
 768   1      
 769   1        TI0=0;
 770   1      }
 771          
 772          void Send_GPS(void)
 773          {
 774   1        unsigned char i;
 775   1        unsigned char CK1;
 776   1        unsigned char CK2;
 777   1        short int j=0;
 778   1      
 779   1          STI=0;
 780   1          j=j+'$';
 781   1          CCF1=1;
 782   1          TDR='$';
 783   1          while(!STI);         //send startup signal:$SJQQB,
 784   1          STI=0;
 785   1              
 786   1          j=j+'S';    
 787   1          CCF1=1;
 788   1          TDR='S';
 789   1          while(!STI);       
 790   1          STI=0;
 791   1              
 792   1          j=j+'J';
 793   1          CCF1=1;
 794   1          TDR='J';
 795   1          while(!STI);
 796   1          STI=0;
C51 COMPILER V8.02   F334                                                                  07/13/2006 10:09:54 PAGE 14  

 797   1              
 798   1          j=j+'Q';
 799   1          CCF1=1;     
 800   1          TDR='Q';
 801   1          while(!STI);
 802   1          STI=0;
 803   1        
 804   1          j=j+'Q';
 805   1          CCF1=1;
 806   1          TDR='Q';
 807   1          while(!STI);
 808   1          STI=0;
 809   1              
 810   1          j=j+'C';
 811   1          CCF1=1;     
 812   1          TDR='C';
 813   1          while(!STI);
 814   1          STI=0;
 815   1              
 816   1          j=j+',';
 817   1          CCF1=1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -