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

📄 main.lst

📁 一个数字温度计源代码 MCU是AT89S52 温度传感器是DS18B20 温度测量范围-30 - 100 精度0.5度
💻 LST
字号:
C51 COMPILER V8.08   MAIN                                                                  12/13/2007 14:04:03 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil_c51\C51\BIN\C51.EXE main.c BROWSE

line level    source

   1          //
   2          
   3          #include "REG52.h"
   4          #include "LedLib.h"
   5          #include "SensorLib.h"
   6          
   7          
   8          void main(void){
   9   1              unsigned char tempL,tempH;//the low byte and the high byte for the temperature
  10   1          char temperature;//store the final result for the convertion
  11   1              unsigned char ledTemp;
  12   1              unsigned char bitCount;
  13   1              unsigned int i;
  14   1              bit minus;
  15   1      
  16   1              //for debug
  17   1              //unsigned char tmp;
  18   1      
  19   1                      
  20   1              //first we setting up the sensor
  21   1              resetSensor();
  22   1              writeSensor(SKIP_ROM);//skip search ROM, address all the ROM present on the bus
  23   1              writeSensor(WRITE_RAM);//start  to configuring the sensor
  24   1              writeSensor(0x64);//Th = 100C
  25   1              writeSensor(0x8a);//Tl = -10C
  26   1              writeSensor(0x1f);//9 bit resolution,0.5C increasment
  27   1              
  28   1              /*
  29   1              //for debug
  30   1              resetSensor();
  31   1              writeSensor(READ_ROM);
  32   1              tmp = readSensor();
  33   1              readSensor();
  34   1              readSensor();
  35   1              resetSensor();
  36   1              
  37   1              for(;1;){
  38   1                      ledTemp = tmp;
  39   1                              bitCount = 0;
  40   1                              do{
  41   1                                      ledSetDigit((ledTemp % 10),bitCount,0);
  42   1                                      ledTemp = ledTemp / 10;
  43   1                                      bitCount ++;
  44   1                              }while(ledTemp != 0);                                   
  45   1                      
  46   1              }
  47   1              */
  48   1              
  49   1              //the whole program is a infinited loop
  50   1              //we read the temperature sensor, and then send it to the led
  51   1              for(;1;){
  52   2                      
  53   2                      resetSensor();//reset the sensor
  54   2                      writeSensor(SKIP_ROM);//skip search ROM, address all the ROM present on the bus
  55   2                      writeSensor(CONVERT_T);//start temperature convert
C51 COMPILER V8.08   MAIN                                                                  12/13/2007 14:04:03 PAGE 2   

  56   2                      
  57   2                      for(i = 0;i < 1000;i++){//we show up the last result while we are waiting for the convertion 
  58   3                              ledTemp = temperature;                                                                                 
             -                                              
  59   3                              if(minus == 1){
  60   4                                      ledSetDigit(5,0,0);//set digit 5                
  61   4                              }else{
  62   4                                      ledSetDigit(0,0,0);//set digit 5
  63   4                              }                       
  64   3                              
  65   3                              bitCount = 1;
  66   3                              do{
  67   4                                      if(bitCount == 1){
  68   5                                              ledSetDigit((ledTemp % 10),bitCount,1); 
  69   5                                      }else{
  70   5                                              ledSetDigit((ledTemp % 10),bitCount,0);
  71   5                                      }
  72   4                                      ledTemp = ledTemp / 10;
  73   4                                      bitCount ++;
  74   4                              }while(ledTemp != 0);
  75   3      
  76   3                              if(temperature < 0){
  77   4                                      ledSetDigit(10,bitCount,0);     
  78   4                              }
  79   3      
  80   3                                      
  81   3                      }
  82   2                                      
  83   2                      resetSensor();//reset the sensor
  84   2                      writeSensor(SKIP_ROM);//skip search ROM, address all the ROM present on the bus
  85   2                      writeSensor(READ_RAM);//read out the result
  86   2                      tempL = readSensor();//read out the higher byte for the temperature
  87   2                      tempH = readSensor();//read out the lower bute for the temperature      
  88   2      
  89   2                      if(tempL & 0x08){
  90   3                              minus = 0x1;
  91   3                      }else{
  92   3                              minus = 0x0;
  93   3                      }
  94   2      
  95   2                      temperature = tempH << 4;
  96   2                      temperature = temperature + ((tempL & 0xf0) >> 4);
  97   2                      temperature = temperature - 10;
  98   2                                                      
  99   2              }       
 100   1      
 101   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    204    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       7
   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 + -