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

📄 lcd.lst

📁 用51单片机做数字温度计PCB资料
💻 LST
字号:
C51 COMPILER V7.06   LCD                                                                   03/27/2009 21:27:11 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.OBJ
COMPILER INVOKED BY: E:\单片机\Keil uVision v2.0\C51\BIN\C51.EXE LCD.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          //uchar code table1[]="I like school!";
  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   LCD                                                                   03/27/2009 21:27:11 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          void main()
  92          {
  93   1              initlcd();
  94   1              write_com(0x80);
  95   1              for(num=0;num<12;num++)
  96   1              {
  97   2                      write_data(table[num]);
  98   2                      delay(20);
  99   2              }
 100   1              delay(2000);
 101   1              write_com(0x80+0x0f);
 102   1              write_data(readtemperature());
 103   1              
 104   1              
 105   1              while(1);
 106   1      }
 107          
 108          void initlcd()
 109          {
 110   1              write_com(0x38);
 111   1              write_com(0x0f);
 112   1              write_com(0x06);
 113   1              write_com(0x80);
 114   1      
 115   1      }
 116          
 117          uchar busy()
C51 COMPILER V7.06   LCD                                                                   03/27/2009 21:27:11 PAGE 3   

 118          {
 119   1              bit result;
 120   1              RS=0;
 121   1              RW=1;
 122   1              E=0;
 123   1              E=1;
 124   1              delay(1);
 125   1              result=(uchar)(P0 & 0x80);
 126   1              delay(1);
 127   1              E=0;
 128   1              delay(1);
 129   1              return result;
 130   1      }
 131          void write_com(uchar n)
 132          {
 133   1              while(busy());
 134   1              RW=0;
 135   1              RS=1;
 136   1              RS=0;
 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=1;
 145   1      }
 146          void write_data(uchar n)
 147          {
 148   1              while(busy());
 149   1              RW=0;
 150   1              RS=0;
 151   1              RS=1;
 152   1              P1=n;
 153   1              E=0;
 154   1              delay(5);
 155   1              E=1;
 156   1              delay(5);
 157   1              E=0;
 158   1              delay(5);
 159   1              RS=0;
 160   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 + -