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

📄 main.lst

📁 用C8051F芯片完成的温度远程采集程序,发送,接受两个模块通信完成,内嵌CRC算法.
💻 LST
字号:
C51 COMPILER V8.02   MAIN                                                                  07/13/2007 17:09:26 PAGE 1   


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

line level    source

   1          #include <c8051f020.h>
   2          #include <absacc.h>
   3          #include <intrins.h>
   4          #include "lcd_driver.h"
   5          #include "delay.h"
   6          #include "crc.h"
   7          
   8          //------------------------
   9          #define uchar unsigned char
  10          #define uint  unsigned int
  11          
  12          
  13          sfr16 DP       = 0x82;                 // data pointer
  14          sfr16 TMR3RL   = 0x92;                 // Timer3 reload value
  15          sfr16 TMR3     = 0x94;                 // Timer3 counter
  16          sfr16 ADC0     = 0xbe;                 // ADC0 data
  17          sfr16 ADC0GT   = 0xc4;                 // ADC0 greater than window
  18          sfr16 ADC0LT   = 0xc6;                 // ADC0 less than window
  19          sfr16 RCAP2    = 0xca;                 // Timer2 capture/reload
  20          sfr16 T2       = 0xcc;                 // Timer2
  21          sfr16 RCAP4    = 0xe4;                 // Timer4 capture/reload
  22          sfr16 T4       = 0xf4;                 // Timer4
  23          sfr16 DAC0     = 0xd2;                 // DAC0 data
  24          sfr16 DAC1     = 0xd5;                 // DAC1 data
  25          
  26          
  27          void  SYSCLK_Init(void);
  28          void  PORT_Init(void);
  29          void  Uart0_Init(void);
  30          void  PCA0_Init(void);
  31          void  ADC0_Init(void);
  32          void  adc_cns(void);
  33          
  34          #define sysclk         22118400        // SYSCLK frequency in Hz
  35          #define baudrate       2400          // Baud rate of UART in bps
  36          #define length         18                  //数据长度 + 两字节CRC值
  37          
  38          
  39          uchar code welcome[]="    Welcome     Innovation Lab  ";
  40          
  41          float temp;
  42          uchar xdata buffer[length+1];
  43          bit   enable;
  44          
  45          extern uchar a;
  46          
  47          //-----------------------------------------------------------------------------
  48          // MAIN Routine
  49          //-----------------------------------------------------------------------------
  50          
  51          void main (void)
  52          {  uchar i;
  53   1         SYSCLK_Init();                     // initialize oscillator
  54   1         PORT_Init();                       // initialize crossbar and GPIO
  55   1         LCD_Init();
C51 COMPILER V8.02   MAIN                                                                  07/13/2007 17:09:26 PAGE 2   

  56   1         LCD_string(1,1,welcome);                       // 欢迎使用界面
  57   1      
  58   1         Uart0_Init();
  59   1         buffer[length] = 0;
  60   1                                    
  61   1         EA = 1;            
  62   1         while(1)
  63   1          {  
  64   2                 while(RI0 == 0);
  65   2                 if(SBUF0==0xff)                                  //收到起始码,开始接收数据
  66   2                   enable=1;
  67   2                 RI0 = 0;
  68   2                      
  69   2                 if(enable == 1)
  70   2                  {            
  71   3                         for(i=0;i<length+1;i++)              //增加结束码
  72   3                          {  
  73   4                                 while(RI0 == 0);
  74   4                                 if(SBUF0==0xfe)                  //收到结束码,停止接收数据
  75   4                                  {
  76   5                                        enable = 0;
  77   5                                        buffer[length] = 0;                  //使数组最后一位为0,避免显示错误
  78   5                                        if(CRC16_Check(buffer,length)==1)        //CRC校验,正确时更新数据显示
  79   5                              {
  80   6                                       LCD_string(1,1,buffer+2);
  81   6                              }
  82   5                                        break;                                                           //跳出FOR循环
  83   5                                       }
  84   4                                  else
  85   4                                buffer[i] = SBUF0;
  86   4                              RI0 = 0;
  87   4                          }
  88   3                       }
  89   2                
  90   2              }
  91   1      }
  92          
  93          
  94          void SYSCLK_Init (void)
  95          {
  96   1         int i;                              // delay counter
  97   1         WDTCN = 0xde;                       // disable watchdog timer
  98   1         WDTCN = 0xad;    
  99   1      
 100   1         OSCXCN = 0x67;                      // start external oscillator with
 101   1         for (i=0; i < 256; i++);            // XTLVLD blanking interval (>1ms)
 102   1         while (!(OSCXCN & 0x80));           // Wait for crystal osc. to settle
 103   1         OSCICN = 0x88;                      // select external oscillator as SYSCLK
 104   1                                             // source and enable missing clock
 105   1                                             // detector
 106   1      }
 107          
 108          //-----------------------------------------------------------------------------
 109          // PORT_Init
 110          //-----------------------------------------------------------------------------
 111          //
 112          // Configure the Crossbar and GPIO ports
 113          //
 114          void PORT_Init (void)
 115          {
 116   1         XBR0    = 0x0c;                     // 串口0允许
 117   1         XBR1    = 0x00;
C51 COMPILER V8.02   MAIN                                                                  07/13/2007 17:09:26 PAGE 3   

 118   1         XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
 119   1         
 120   1         P0MDOUT |= 0x03;
 121   1         P1MDOUT = 0xff;
 122   1         //P2MDOUT = 0xff;
 123   1         //P3MDOUT = 0xff;
 124   1         P74OUT  = 0xff;                    // P4-P7配置为推挽方式
 125   1      
 126   1      }
 127          
 128          
 129          void Uart0_Init(void)
 130          {
 131   1         SCON0  = 0x50;                      // SCON0: mode 1, 8-bit UART, disenable RX       //0x50 enable RX
 132   1         TMOD  |= 0x20;                      // TMOD: timer 1, mode 2, 8-bit reload
 133   1         TH1    = -(sysclk/baudrate/192);     // set Timer1 reload value for baudrate
 134   1         CKCON |= 0x00;                      // Timer1 uses SYSCLK/12 as time base
 135   1         PCON  |= 0x80;                      // SMOD0 = 1
 136   1         TR1    = 1;                         // start Timer1
 137   1         //ES0    = 1;                         // enable UART0 interrupts
 138   1      }
 139          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    192    ----
   CONSTANT SIZE    =     33    ----
   XDATA SIZE       =     19    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      4       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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