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

📄 lcd18b20.lst

📁 用51单片机做数字温度计PCB资料
💻 LST
字号:
C51 COMPILER V7.06   LCD18B20                                                              03/28/2009 15:07:10 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LCD18B20
OBJECT MODULE PLACED IN LCD18b20.OBJ
COMPILER INVOKED BY: E:\单片机\Keil uVision v2.0\C51\BIN\C51.EXE LCD18b20.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<reg52.h>
   2          
   3          
   4          #define uchar unsigned char
   5          #define uint unsigned int
   6          
   7          sbit RS=P2^5;
   8          sbit RW=P2^6;
   9          sbit E=P2^7;
  10          sbit DQ=P1^0;
  11          
  12          uchar code table[]="temperature:";
  13          
  14          uchar num;
  15          
  16          //void initlcd();
  17          void write_com(uchar n);
  18          void write_data(uchar n);
  19          //void delay(uint n);
  20          //uchar busy();
  21          
  22          uchar temperature,tl,th;
  23          
  24          void delay(uint n)
  25          {
  26   1              uint x,y;
  27   1              for(x=n;x>0;x--)
  28   1                      for(y=112;y>0;y--)
  29   1                                      ;
  30   1      }
  31          
  32          void init()
  33          {
  34   1              uchar x=0;
  35   1          DQ=1;
  36   1              delay(5);
  37   1              DQ=0;
  38   1              delay(500);
  39   1              DQ=1;
  40   1              delay(15);
  41   1      }
  42          
  43          uchar read()
  44          {
  45   1              uchar i=0;
  46   1              uchar dat=0;
  47   1              for(i=8;i>0;i--)
  48   1              {
  49   2                      DQ=1;
  50   2                      delay(2);
  51   2                      DQ=0;
  52   2                      dat>>=1;
  53   2                      DQ=1;
  54   2                      if(DQ!=0)
  55   2                              dat|=0x80;
C51 COMPILER V7.06   LCD18B20                                                              03/28/2009 15:07:10 PAGE 2   

  56   2                      delay(4);
  57   2              }
  58   1              return(dat);
  59   1      }
  60          
  61          void write(uchar dat)
  62          {
  63   1              uchar i=0;
  64   1              for(i=8;i>0;i--)
  65   1              {
  66   2                      DQ=0;
  67   2                      DQ=dat&0x01;
  68   2                      delay(5);
  69   2                      DQ=1;
  70   2                      dat>>=1;
  71   2              }
  72   1              delay(5);
  73   1      }
  74          uchar readtemperature()
  75          {
  76   1              init();
  77   1              write(0xcc);
  78   1              write(0x44);
  79   1              delay(150);
  80   1              init();
  81   1              write(0xcc);
  82   1              write(0xbe);
  83   1              tl=read();
  84   1              th=read();
  85   1              temperature=(th*256+tl)*0.0625;
  86   1              delay(200);
  87   1              return (temperature);   
  88   1      }
  89          
  90          
  91          
  92          
  93          void initlcd()
  94          {
  95   1              write_com(0x38);
  96   1              write_com(0x0f);
  97   1              write_com(0x06);
  98   1              write_com(0x80);
  99   1      
 100   1      }
 101          
 102          uchar busy()
 103          {
 104   1              bit result;
 105   1              RS=0;
 106   1              RW=1;
 107   1              E=0;
 108   1              E=1;
 109   1              delay(1);
 110   1              result=(uchar)(P0 & 0x80);
 111   1              delay(1);
 112   1              E=0;
 113   1              delay(1);
 114   1              return result;
 115   1      }
 116          void write_com(uchar n)
 117          {
C51 COMPILER V7.06   LCD18B20                                                              03/28/2009 15:07:10 PAGE 3   

 118   1              while(busy());
 119   1              RW=0;
 120   1              RS=1;
 121   1              RS=0;
 122   1              P1=n;
 123   1              E=0;
 124   1              delay(5);
 125   1              E=1;
 126   1              delay(5);
 127   1              E=0;
 128   1              delay(5);
 129   1              RS=1;
 130   1      }
 131          void write_data(uchar n)
 132          {
 133   1              while(busy());
 134   1              RW=0;
 135   1              RS=0;
 136   1              RS=1;
 137   1              P1=n;
 138   1              E=0;
 139   1              delay(5);
 140   1              E=1;
 141   1              delay(5);
 142   1              E=0;
 143   1              delay(5);
 144   1              RS=0;
 145   1      }
 146          void main()
 147          {
 148   1              initlcd();
 149   1              write_com(0x80);
 150   1              for(num=0;num<12;num++)
 151   1              {
 152   2                      write_data(table[num]);
 153   2                      delay(20);
 154   2              }
 155   1              delay(2000);
 156   1              write_com(0x80+0x0f);
 157   1              write_data(readtemperature());
 158   1              
 159   1              
 160   1              while(1);
 161   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    394    ----
   CONSTANT SIZE    =     13    ----
   XDATA SIZE       =   ----    ----
   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 + -