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

📄 1602driver.lst

📁 模数转换器AD2543驱动
💻 LST
字号:
C51 COMPILER V8.05a   1602DRIVER                                                           09/07/2007 02:51:32 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE 1602DRIVER
OBJECT MODULE PLACED IN 1602driver.OBJ
COMPILER INVOKED BY: D:\C51\BIN\C51.EXE 1602driver.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h>
   2          //#include <stdlib.h>
   3          
   4          
   5          #define Port P2
   6          
   7          sbit RS = P1^0;
   8          sbit RW = P1^1;
   9          sbit E = P1^2;
  10          //sbit P1_4=P1^4;
  11          //sbit P1_5=P1^5;
  12          
  13          unsigned char ReadState_LCD(void);
  14          unsigned char IsBusy_LCD(void);
  15          void WriteData_LCD(unsigned char Data);
  16          void WriteCommand_LCD(unsigned char Code);
  17          void Init_LCD(void);
  18          
  19           void PutStr_LCD(unsigned char *str);
  20          void PutStrXY_LCD(unsigned char x, unsigned char y, unsigned char *str);
  21          void PutIntXY_LCD(unsigned char x, unsigned char y, unsigned Num);
  22          void PutNumXY_LCD(unsigned char x, unsigned char y, unsigned Num, unsigned char Len);
  23          void SetPos_LCD(unsigned char x, unsigned char y);
  24          
  25           
  26          
  27          
  28          unsigned char ReadState_LCD(void)                                               //char ReadState_LCD
  29          {
  30   1              Port = 0xff;
  31   1              RS = 0;
  32   1              RW = 1;
  33   1              E = 1;
  34   1      
  35   1              return Port;
  36   1      }
  37          
  38          unsigned char IsBusy_LCD(void)                                                  //IsBusy_LCD
  39          {
  40   1              Port = 0xff;
  41   1              RS = 0;
  42   1              RW = 1;
  43   1              E = 1;
  44   1      
  45   1      //      return (Port >> 7) & 0x01;
  46   1              return Port&0x80;
  47   1      }
  48          
  49          void WriteData_LCD(unsigned char Data)                                   //WriteData_LCD
  50          {
  51   1              while ( IsBusy_LCD() );
  52   1      
  53   1              RS = 1;
  54   1              RW = 0;
  55   1      
C51 COMPILER V8.05a   1602DRIVER                                                           09/07/2007 02:51:32 PAGE 2   

  56   1              Port = Data;
  57   1      
  58   1              E = 0;
  59   1              E = 1;
  60   1              E = 0;
  61   1      }
  62          
  63          void WriteCommand_LCD(unsigned char Code)                                //WriteCommand_LCD
  64          {
  65   1              while ( IsBusy_LCD() );
  66   1      
  67   1              RS = 0;
  68   1              RW = 0;
  69   1              Port = Code;
  70   1      
  71   1              E = 0;
  72   1              E = 1;
  73   1              E = 0;
  74   1      }
  75             void delay(unsigned time)                                                       //void delay
  76          {
  77   1              while(time--);
  78   1      }
  79          
  80          void Init_LCD(void)                                                                             //Init_LCD
  81          {
  82   1              delay(15000);
  83   1              WriteCommand_LCD(0x38);
  84   1              delay(5000);
  85   1              WriteCommand_LCD(0x38);
  86   1              delay(5000);
  87   1              WriteCommand_LCD(0x38);
  88   1              delay(5000);
  89   1              WriteCommand_LCD(0x38);
  90   1              WriteCommand_LCD(0x0f);
  91   1              WriteCommand_LCD(0x08);
  92   1              WriteCommand_LCD(0x01);
  93   1              WriteCommand_LCD(0x06);
  94   1              WriteCommand_LCD(0x0c);
  95   1              WriteCommand_LCD(0x80);
  96   1      }
  97          
  98          
  99          void PutStr_LCD(unsigned char *str)                                        //PutStr_LCD
 100          {
 101   1              while(*str)
 102   1              {
 103   2                      WriteData_LCD(*str++);
 104   2              }
 105   1      }
 106          
 107          void PutStrXY_LCD(unsigned char x, unsigned char y, unsigned char *str) //PutStrXY_LCD
 108          {
 109   1              SetPos_LCD(x, y);
 110   1              PutStr_LCD(str);
 111   1      }
 112          
 113          void PutIntXY_LCD(unsigned char x, unsigned char y, unsigned Num)               //PutIntXY_LCD
 114          {
 115   1              unsigned char i = 0;
 116   1              unsigned char Len = 1;
 117   1      
C51 COMPILER V8.05a   1602DRIVER                                                           09/07/2007 02:51:32 PAGE 3   

 118   1              if(Num >= 10)           Len++;
 119   1              if(Num >= 100)          Len++;
 120   1              if(Num >= 1000)         Len++;
 121   1              if(Num >= 10000)        Len++;
 122   1      
 123   1              for(i = 0; i < Len; i++) 
 124   1              {
 125   2                      SetPos_LCD(x + Len - i - 1, y);
 126   2                      WriteData_LCD(Num % 10 + 48);
 127   2                      Num /= 10;
 128   2              }
 129   1      }
 130          
 131          void PutNumXY_LCD(unsigned char x, unsigned char y, unsigned Num, unsigned char Len) //PutNumXY_LCD
 132          {
 133   1              unsigned char i = 0;
 134   1              unsigned char Add = ReadState_LCD() & 0x7f;
 135   1      
 136   1              for(i = 0; i < Len; i++)
 137   1              {
 138   2                      SetPos_LCD(x + Len - i - 1, y);
 139   2                      WriteData_LCD(Num % 10 + 48);
 140   2                      Num /= 10;
 141   2              }
 142   1      }
 143          
 144          void SetPos_LCD(unsigned char x, unsigned char y)                 //SetPos_LCD
 145          {
 146   1              unsigned char i = y * 0x40 + x;
 147   1      
 148   1              WriteCommand_LCD(0x80 + i);
 149   1      }
 150          
 151          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    406    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      19
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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