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

📄 lcd.lst

📁 16×2点阵字符型LCD模块间接控制方式电路原理图及Keil C51驱动程序-display
💻 LST
字号:
C51 COMPILER V8.02   LCD                                                                   04/10/2008 17:17:55 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lcd.c OPTIMIZE(7,SPEED) BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg52.h>    
   2          #define uchar unsigned char
   3          idata char flag0 ;
   4          idata char flag1 ;
   5          idata char flag2 ;
   6          idata char flag3 ;
   7          idata char flag4 ;
   8          idata char flag5 ;
   9          idata char flag6 ;
  10          idata char flag7 ;
  11          sbit RS=P2^3;
  12          sbit RW=P2^4;
  13          sbit LCDE=P2^5;
  14          sbit big=P3^2;
  15          sbit fd=P3^3;
  16          unsigned char line1[16],line2[16];
  17          unsigned char code cgram1[64]={0x00,0x1f,0x12,0x09,0x1f,0x11,0x01,0x0f,
  18          0x1e,0x04,0x04,0x08,0x1f,0x01,0x00,0x1e,
  19          0x02,0x03,0x06,0x05,0x04,0x09,0x09,0x12,
  20          0x00,0x1c,0x04,0x08,0x10,0x18,0x04,0x07,
  21          0x00,0x0f,0x09,0x09,0x0f,0x09,0x09,0x0f,0x00,0x1c,0x04,0x04,0x1c,0x04,0x04,0x1c,
  22          0x00,0x04,0x14,0x14,0x14,0x04,0x04,0x03,0x00,0x12,0x13,0x11,0x01,0x04,0x04,0x1c};/
*** ERROR C141 IN LINE 22 OF LCD.C: syntax error near '/'
  23          
  24          
  25          void delay5ms()
  26          {
  27   1              register int i;
  28   1              for (i=0;i<1000;i++)
  29   1              ;
  30   1      }
  31          
  32          void delay50us()
  33          {
  34   1              register int i;
  35   1              for (i=0;i<20;i++)
  36   1              ;
  37   1      }
  38          
  39          wr_com(unsigned char comm)
  40          {
  41   1                      LCDE=0;
  42   1                      RS=0;
  43   1                      RW=0;
  44   1                      LCDE=1;
  45   1                      P0=comm;
  46   1                      RS=0;
  47   1                      RW=0;
  48   1                      LCDE=0;
  49   1      }
  50          
  51          wr_data(unsigned char dat)
  52          {
  53   1                      LCDE=0;
  54   1                      RS=0;
C51 COMPILER V8.02   LCD                                                                   04/10/2008 17:17:55 PAGE 2   

  55   1                      RW=0;
  56   1                      RS=1;
  57   1                      RW=0;
  58   1                      LCDE=1;
  59   1                      P0=dat;
  60   1                      LCDE=0;
  61   1                      RS=0;
  62   1                      RW=0;
  63   1      }
  64          
  65          
  66          unsigned char rd_bf()
  67          {
  68   1                      unsigned char i;
  69   1                      P0=0xff;
  70   1                      LCDE=0;
  71   1                      RS=0;
  72   1                      RW=0;
  73   1                      RS=0;
  74   1                      RW=1;
  75   1                      LCDE=1;
  76   1                      i=P0;
  77   1                      LCDE=0;
  78   1                      return(i);
  79   1      }
  80                  
  81          void init()
  82          {
  83   1              unsigned char in,i;
  84   1              wr_com(0x30);
  85   1              delay5ms();
  86   1              wr_com(0x30);
  87   1              delay5ms();
  88   1              wr_com(0x30);
  89   1              delay5ms();
  90   1              in=rd_bf();
  91   1              delay5ms();
  92   1              wr_com(0x01);
  93   1              delay5ms();
  94   1              in=rd_bf();
  95   1              delay5ms();
  96   1              wr_com(0x06);
  97   1              delay5ms();
  98   1              in=rd_bf();
  99   1              delay50us();
 100   1              wr_com(0x38);
 101   1              delay50us();
 102   1              in=rd_bf();
 103   1              delay50us();
 104   1              wr_com(0x0c);
 105   1              delay50us();
 106   1              in=rd_bf();
 107   1              delay50us();
 108   1              
 109   1              wr_com(0x40);           //set cgram address
 110   1              delay50us();
 111   1              in=rd_bf();
 112   1              delay50us();
 113   1              for(i=0;i<64;i++)
 114   1              {
 115   2                      wr_data(cgram1[i]);             //display "0"
 116   2                      delay50us();
C51 COMPILER V8.02   LCD                                                                   04/10/2008 17:17:55 PAGE 3   

 117   2                      in=rd_bf();
 118   2              }
 119   1              
 120   1              
 121   1      
 122   1      
 123   1      
 124   1      
 125   1      
 126   1      
 127   1      }
 128          
 129          
 130          display_162()
 131          {
 132   1                              unsigned char in,i;
 133   1                      wr_com(0x80);           //set ram address
 134   1                      delay50us();
 135   1                      in=rd_bf();
 136   1                      delay50us();
 137   1                      for(i=0;i<16;i++)
 138   1                      {
 139   2                              wr_data(line1[i]);              //display "0"
 140   2                              delay50us();
 141   2                              in=rd_bf();
 142   2                      }
 143   1                      in=rd_bf();
 144   1                      delay50us();
 145   1                      wr_com(0xc0);
 146   1                      delay50us();
 147   1                      in=rd_bf();
 148   1                      delay50us();
 149   1                      for(i=0;i<16;i++)
 150   1                      {
 151   2                              wr_data(line2[i]);              //display "0"
 152   2                              delay50us();
 153   2                              in=rd_bf();
 154   2                      }
 155   1      }
 156          main()
 157          {
 158   1              unsigned char in,i,da;
 159   1              delay5ms();
 160   1              delay5ms();
 161   1              delay5ms();
 162   1              delay5ms();
 163   1                 
 164   1                      
 165   1              init(); 
 166   1      
 167   1              while(1)
 168   1              {
 169   2                      if(fd==1)
 170   2                      {
 171   3                                      line1[0]=0x20;
 172   3                                      line1[1]=0;             //display "爱思"
 173   3                                      line1[2]=1;
 174   3                                      line1[3]=4;
 175   3                                      line1[4]=5;
 176   3                                      line1[5]=0x20;
 177   3                                      line1[6]=0;             //display "爱思"
 178   3                                      line1[7]=1;
C51 COMPILER V8.02   LCD                                                                   04/10/2008 17:17:55 PAGE 4   

 179   3                                      line1[8]=4;
 180   3                                      line1[9]=5;
 181   3                                      line1[10]=0x20;
 182   3                                      line1[11]=0;            //display "爱思"
 183   3                                      line1[12]=1;
 184   3                                      line1[13]=4;
 185   3                                      line1[14]=5;
 186   3                                      line1[15]=0x20;
 187   3                                      
 188   3                                      line2[0]=0x20;
 189   3                                      line2[1]=2;             //display "爱思"
 190   3                                      line2[2]=3;
 191   3                                      line2[3]=6;
 192   3                                      line2[4]=7;
 193   3                                      line2[5]=0x20;
 194   3                                      line2[6]=2;             //display "爱思"
 195   3                                      line2[7]=3;
 196   3                                      line2[8]=6;
 197   3                                      line2[9]=7;
 198   3                                      line2[10]=0x20;
 199   3                                      line2[11]=2;            //display "爱思"
 200   3                                      line2[12]=3;
 201   3                                      line2[13]=6;
 202   3                                      line2[14]=7;
 203   3                                      line2[15]=0x20;
 204   3                              
 205   3                      }       
 206   2              else if(big==1)
 207   2              {
 208   3                      da=0x41;
 209   3                      for(i=0;i<16;i++)
 210   3                      {
 211   4                              line1[i]=da;
 212   4                              da++;   
 213   4                      }
 214   3                      
 215   3                      
 216   3                      da=0x51;
 217   3                      for(i=0;i<16;i++)
 218   3                      {
 219   4                              line2[i]=da;
 220   4                              da++;   
 221   4                      }
 222   3              }
 223   2              else
 224   2              {
 225   3                      da=0x61;
 226   3                      for(i=0;i<16;i++)
 227   3                      {
 228   4                              line1[i]=da;
 229   4                              da++;   
 230   4                      }
 231   3                      
 232   3                      
 233   3                      da=0x71;
 234   3                      for(i=0;i<16;i++)
 235   3                      {
 236   4                              line2[i]=da;
 237   4                              da++;   
 238   4                      }
 239   3              }
 240   2              display_162();  
C51 COMPILER V8.02   LCD                                                                   04/10/2008 17:17:55 PAGE 5   

 241   2              }
 242   1      }

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

⌨️ 快捷键说明

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