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

📄 lcd1602.lst

📁 基于51单片机的CA1602A液晶显示,串行传输,键盘编码等源代码
💻 LST
字号:
C51 COMPILER V6.12  LCD1602                                                                04/21/2008 21:42:01 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE LCD1602
OBJECT MODULE PLACED IN .\Lcd1602.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\Lcd1602.c DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          
   3          #include <REG51.H>
   4          #include<absacc.h>
   5          #include <stdio.h>
   6          #include <STRING.H>
   7          #include <MATH.H>
   8          #define DB P0
   9          
  10          #define uchar unsigned char
  11          #define uint  unsigned int
  12          
  13          
  14          sbit RS=P2^0;  
  15          sbit RW=P2^1;  
  16          sbit E=P2^2;
  17          
  18          ////延时函数//////////
  19          void msec(unsigned int x)    
  20            {
  21   1         uchar j;
  22   1         while(x--)
  23   1         {
  24   2             for (j=0;j<125;j++)
  25   2             {;}
  26   2         }
  27   1        }
  28          
  29          
  30          //液晶配置函数
  31          void  configure(uchar com)  //com配置参数,初始化时需要配置若干次
  32             {
  33   1          uchar m; 
  34   1          RS=0;
  35   1          RW=1;
  36   1       do
  37   1         {
  38   2          DB=0x0ff;
  39   2          E=1;
  40   2          m=DB;
  41   2          E=0;
  42   2          m=m&0x80;
  43   2          }
  44   1       while (m==0x80);  
  45   1          RW=0;
  46   1          DB=com;
  47   1          E=1;
  48   1          E=0;    
  49   1      }
  50          
  51          void LcdIni()
  52          {
  53   1      
  54   1         DB=0x30;
  55   1         RS=0;
C51 COMPILER V6.12  LCD1602                                                                04/21/2008 21:42:01 PAGE 2   

  56   1         RW=0;
  57   1      
  58   1      
  59   1      
  60   1         msec(0x15); 
  61   1      
  62   1         DB=0x38;
  63   1         E=1;
  64   1         E=0;
  65   1      
  66   1        configure(0x01);
  67   1        configure(0x0c);
  68   1        configure(0x06);
  69   1      }
  70          
  71          
  72          
  73          //显示函数   
  74          
  75          void  printchar(uchar row,uchar col, buf )
  76           {
  77   1      
  78   1      	 uchar cod;
  79   1           uchar m;
  80   1      	 cod=0x80;
  81   1      	 if(row==1) cod=cod+0x40;
  82   1           if(row==2) cod=cod+0x14;
  83   1      	 if(row==3) cod=cod+0x54;
  84   1      	 cod=cod+col;
  85   1      	 //cod=0x80 + 0x10 * row + col/2; 
  86   1           configure(cod);
  87   1      
  88   1      	   
  89   1      
  90   1      	   RS=0;
  91   1      	   RW=1;
  92   1      
  93   1             do
  94   1              {
  95   2                 DB=0x0ff;
  96   2                 E=1;
  97   2                 m=DB;
  98   2                 E=0;
  99   2                 m=m&0x80;
 100   2              }
 101   1             while (m==0x80);  
 102   1                RS=1;
 103   1      	      RW=0;
 104   1      	      DB=buf;
 105   1      	      E=1;
 106   1      	      E=0;
 107   1       
 108   1      
 109   1       }
 110          //-------------
 111          
 112          void  print(uchar row,uchar col,char * buf,uchar len )
 113           {
 114   1      	 uchar i;
 115   1      	 uchar cod;
 116   1           uchar m;
 117   1      	 cod=0x80;
C51 COMPILER V6.12  LCD1602                                                                04/21/2008 21:42:01 PAGE 3   

 118   1      	 if(row==1) cod=cod+0x40;
 119   1           if(row==2) cod=cod+0x14;
 120   1      	 if(row==3) cod=cod+0x54;
 121   1      	 cod=cod+col;
 122   1      	 //cod=0x80 + 0x10 * row + col/2; 
 123   1           configure(cod);
 124   1      
 125   1      	   
 126   1           for(i=0;i<len;i++)
 127   1           {
 128   2      	   RS=0;
 129   2      	   RW=1;
 130   2      
 131   2             do
 132   2              {
 133   3                 DB=0x0ff;
 134   3                 E=1;
 135   3                 m=DB;
 136   3                 E=0;
 137   3                 m=m&0x80;
 138   3              }
 139   2             while (m==0x80);  
 140   2                RS=1;
 141   2      	      RW=0;
 142   2      	      DB=buf[i];
 143   2      	      E=1;
 144   2      	      E=0;
 145   2             //msec(0x10);
 146   2      	   }
 147   1      
 148   1      
 149   1       }


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