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

📄 main.lst

📁 矿工定位系统单端
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 1   


C51 COMPILER V7.05, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<REG922.h>
   2          #include <absacc.h>
   3          #include "string.h"
   4          #include "intrins.h"
   5          
   6          #include "ports.h"
   7          #include "osc.h"
   8          #include "uart.h"
   9          #include "rtc.h"
  10          #include "power.h"
  11          #include "watchdogrtc.h "
  12          #include  "IAP_LITE.H"
  13          bit T_flag=0,set=0,set_ok;
  14          void Send_ok(unsigned char key);
  15          unsigned char ADDR,RX_addr=0,key_tem=01;
  16          unsigned char wring_send_times=0;
  17          
  18          //************************程序用的变量********************
  19          unsigned char data RXtem[6], RXdata[6];//程序接收数据缓冲区
  20          unsigned char data RXNOM,RXSTAT=0;
  21          unsigned char data RXTimerOUT,i; //接收超时
  22          bit rxok;          // 接收完成标志
  23          /****************************************************************************/
  24          
  25          
  26          void Delay100ms(unsigned char x)
  27          {   
  28   1        unsigned char i,j;
  29   1        
  30   1        while(x-- != 0)
  31   1        {  
  32   2          
  33   2              for (j = 0;j < 114; j++)
  34   2              {
  35   3           if(rxok)
  36   3                {
  37   4                  rxok=0;
  38   4                      Send_ok(key_tem);
  39   4                      i=0;
  40   4                }
  41   3              for (i = 0;i < 88; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
  42   4              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  43   4              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  44   4              _nop_() ;_nop_() ;_nop_() ;};
  45   3              }
  46   2        }
  47   1      }
  48          /****************************************************************************/
  49          
  50          
  51          void Delay1ms(unsigned char idata  x)
  52          {   
  53   1        unsigned char i;
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 2   

  54   1        
  55   1        while(x-- != 0)
  56   1        {
  57   2          if(rxok)
  58   2                {
  59   3                  rxok=0;
  60   3                      Send_ok(key_tem);
  61   3                      i=0;
  62   3                }
  63   2          for (i = 0;i < 89; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
  64   3              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  65   3              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  66   3              _nop_() ;_nop_() ;_nop_() ;};
  67   2        }
  68   1      }
  69          /****************************************************************************/
  70          
  71          
  72          void Delay1msa(unsigned char idata  x)
  73          {   
  74   1        unsigned char i;
  75   1        
  76   1        while(x-- != 0)
  77   1        {
  78   2         
  79   2          for (i = 0;i < 89; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
  80   3              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  81   3              _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
             -) ;
  82   3              _nop_() ;_nop_() ;_nop_() ;};
  83   2        }
  84   1      }
  85          /***********************************************************************
  86          DESC:    Initializes UART for mode 1
  87                   Baudrate: 9600
  88          RETURNS: Nothing
  89          CAUTION: If interrupts are being used then EA must be set to 1
  90                   after calling this function
  91          ************************************************************************/
  92          void uart_init(void)
  93          {
  94   1        // configure UART
  95   1        // clear SMOD0
  96   1        PCON &= ~0x40;
  97   1        SCON = 0x50;
  98   1        // set or clear SMOD1
  99   1        PCON &= 0x7f;
 100   1        PCON |= (0 << 8);
 101   1        SSTAT = 0x00;
 102   1      
 103   1        // enable break detect
 104   1        AUXR1 |= 0x40;
 105   1      
 106   1        // configure baud rate generator
 107   1        BRGCON = 0x00;
 108   1        BRGR0 = 0xF0;
 109   1        BRGR1 = 0x02;
 110   1        BRGCON = 0x03;
 111   1      
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 3   

 112   1        // TxD = push-pull, RxD = input
 113   1        P1M1 &= ~0x01;
 114   1        P1M2 |= 0x01;
 115   1        P1M1 |= 0x02;
 116   1        P1M2 &= ~0x02;
 117   1      
 118   1        // initially not busy
 119   1      
 120   1      
 121   1        // set isr priority to 0
 122   1        IP0 &= 0xEF;
 123   1        IP0H &= 0xEF;
 124   1        // enable uart interrupt
 125   1        ES = 0;
 126   1      
 127   1      } // uart_init
 128          /***********************************************************************
 129          DESC:    Initializes the ports
 130          RETURNS: Nothing
 131          CAUTION: Call before the initialization functions of other peripherals
 132          ************************************************************************/
 133          void ports_init(void)
 134          {
 135   1        P0M1 &= 0xF0;
 136   1        P0M2 &= 0xF0;
 137   1      
 138   1        P1M1 |= 0x2C;
 139   1        P1M2 &= 0xDF;
 140   1        P1M2 |= 0x0C;
 141   1      
 142   1      } // ports_init
 143          //*******************add**********************************************
 144          
 145          
 146           /****************************************************************************
 147          *                                                                           *
 148          * Function:     START_T0                                                    *
 149          *                                                                           *
 150          * Input:        -                                                           *
 151          * Output:       -                                                           *
 152          *                                                                           *
 153          * Description:                                                              *
 154          *                                                                           *
 155          *                                                                           *
 156          ****************************************************************************/
 157          void START_T0(unsigned char x)
 158          {
 159   1        ET0 = 0 ;
 160   1        TR0 = 0;
 161   1        RXTimerOUT = x ;
 162   1        TL0 = 0;
 163   1        TH0 = 0;
 164   1        TR0 = 1;
 165   1        ET0 = 1 ;
 166   1      }                
 167          /****************************************************************************
 168          *                                                                           *
 169          * Function:     CALL_isr_T0                                                 *
 170          *                                                                           *
 171          * Input:        -                                                           *
 172          * Output:       -                                                           *
 173          *                                                                           *
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 4   

 174          * Description:                                                              *
 175          *                                                                           *
 176          *                                                                           *
 177          ****************************************************************************/
 178          void CALL_isr_T0(void)
 179          {
 180   1        TR0 = 0;
 181   1        RXTimerOUT = 0; 
 182   1        TF0 = 1;
 183   1      
 184   1      }
 185          
 186          //********************串口中断处理程序**************************************************************
 187          void ub1ISR(void) interrupt 4 using 1
 188          {
 189   1         unsigned char c;
 190   1         if ( RI )                                        // Receive Command
 191   1        {
 192   2         // RXTimerOUT=10;
 193   2          RI = 0;
 194   2              c  = SBUF;
 195   2              
 196   2              switch(RXSTAT)
 197   2              {
 198   3                case 0:                          //接受帧头02
 199   3                       if(c==0x55)
 200   3                     {RXSTAT=1;START_T0(20);}
 201   3                               else
 202   3                     CALL_isr_T0();
 203   3                       break;
 204   3                case 1:                       //接收
 205   3                   if(c==0xaa)
 206   3                                 {  
 207   4                        RXSTAT=2;
 208   4                        START_T0(20);
 209   4                     }
 210   3                   else
 211   3                                { 
 212   4                                  if(c==0xbb)
 213   4                                      { 
 214   5                                         if(!ISP)
 215   5                                              {
 216   6                                               set=1;
 217   6                                           RXSTAT=2;
 218   6                           START_T0(20);
 219   6                                              }
 220   5                                      
 221   5                                       }
 222   4                                      else
 223   4                                      {
 224   5                      RXSTAT=0; 
 225   5                      CALL_isr_T0();
 226   5                                      }
 227   4                     }
 228   3                         
 229   3                              // RXSTAT=0;
 230   3                       break;
 231   3               case 2:
 232   3                      if(c==ADDR)
 233   3                          {
 234   4                   RXSTAT=3;
 235   4                               START_T0(20);
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 5   

 236   4                              }
 237   3                              else
 238   3                               { 
 239   4                      RXSTAT=0; 
 240   4                      CALL_isr_T0();
 241   4                   }
 242   3                               i=0;
 243   3                      break;
 244   3               case 3:
 245   3                      if(c==ADDR)
 246   3                              {
 247   4                               if(set)
 248   4                               {
 249   5                                RXSTAT=4;
 250   5                                START_T0(20);
 251   5                               }
 252   4                               else
 253   4                               {
 254   5                    RXSTAT=0;
 255   5                                rxok=1;
 256   5                    CALL_isr_T0();
 257   5                               }
 258   4                                
 259   4                              }
 260   3                      
 261   3                  break;
 262   3                case 4:
 263   3                      RX_addr=c;
 264   3                              set_ok=1;
 265   3                              set=0;
 266   3                          RXSTAT=0;
 267   3                  CALL_isr_T0();
 268   3                      break;
 269   3                default:
 270   3                   RXSTAT=0;
 271   3                           break;
 272   3              }
 273   2      
 274   2        }
 275   1       else
 276   1       {
 277   2             TI=0;
 278   2                 
 279   2        }
 280   1      }
 281          /*************************原有的函数需改变*************************************
 282          *                                                                           *
 283          * Function:     isr_timer0                                                  *
 284          *                                                                           *
 285          * Input:        -                                                           *
 286          * Output:       -                                                           *
 287          *                                                                           *
 288          * Description:                                                              *
 289          *                                                                           *
 290          *                                                                           *
 291          ****************************************************************************/
 292          void isr_timer0(void) interrupt 1 using 2
 293          {
 294   1        TR0=0;
 295   1         if(RXTimerOUT!=0)        //此if{}else{} 为新加入的判断超时功能
 296   1          { 
 297   2             RXTimerOUT--;
C51 COMPILER V7.05   MAIN                                                                  04/13/2004 13:35:26 PAGE 6   

 298   2          }
 299   1          else
 300   1          {
 301   2            RXSTAT=0;

⌨️ 快捷键说明

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