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

📄 lcd.lst

📁 15寸
💻 LST
字号:
C51 COMPILER V7.20   LCD                                                                   05/08/2005 16:32:09 PAGE 1   


C51 COMPILER V7.20, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE lcd.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <at89x52.h>
   2          #include "lcd.h"
   3          
   4          
   5          
   6          
   7          sbit dc = 0xa2;//0x96;                  //P1.6 LCD的RS          pin7
   8          sbit rw = 0xa1;//0x95;                  //P1.5 LCD的R/W         pin6
   9          sbit cs = 0xa0;//0x94;                  //P1.4 LCD的E           pin5
  10          sfr lcdbus = 0x80;              //P0   LCD的数据 D0 = P0.0
  11          
  12          unsigned char displayPosition = 0;
  13          unsigned char DDRAMAddress = 0;
  14          
  15          
  16          void softNop(void){}
  17          
  18          bit lcd_checkBusy(void)
  19          {
  20   1              unsigned char lcdstate;
  21   1              dc = 0;
  22   1              rw = 1;
  23   1              cs = 1;
  24   1              softNop();
  25   1              lcdstate = lcdbus;
  26   1              cs = 0;
  27   1              return((bit)(lcdstate & 0x80));
  28   1      }
  29          
  30          void lcd_WCmd(unsigned char lcdCmd)     //write LCD command
  31          {
  32   1              while(lcd_checkBusy());
  33   1              lcdbus = lcdCmd;
  34   1              dc = 0;
  35   1              rw = 0;
  36   1              cs = 1;
  37   1              softNop();
  38   1              cs = 0;
  39   1              lcdbus = 0xff;
  40   1      }
  41          
  42          void lcd_WData(unsigned char lcddata)
  43          {
  44   1              while(lcd_checkBusy());
  45   1              lcdbus = lcddata;
  46   1              dc = 1;         //dc = 1 为数据,=0 为命令
  47   1              rw = 0;         //rw = 1 为读,=0 为写
  48   1              cs = 1;         //cs = 1 选通
  49   1              softNop();
  50   1              cs = 0;
  51   1              lcdbus = 0xff;
  52   1      }
  53          
  54          //---------------------------------------------------------
  55          void lcd_setDDRAMAddress(unsigned char DDRAMaddr)
C51 COMPILER V7.20   LCD                                                                   05/08/2005 16:32:09 PAGE 2   

  56          {
  57   1              DDRAMAddress = DDRAMaddr;
  58   1              lcd_WCmd(DDRAMaddr | 0x80);
  59   1         
  60   1      }
  61          
  62          void lcd_cls(void)
  63          {
  64   1              lcd_WCmd(0x01);
  65   1      }
  66          
  67          void lcd_string16(unsigned char position,unsigned char *str)
  68          {
  69   1      
  70   1          unsigned char i = 0;
  71   1      
  72   1              if(position >= 16) position = 0;
  73   1              if(position < 8)
  74   1              {
  75   2                      lcd_setDDRAMAddress(position);
  76   2              }
  77   1              if(position >=8)
  78   1              {
  79   2                      position = position - 8;
  80   2                      position = position + 0x40;
  81   2                      lcd_setDDRAMAddress(position);
  82   2              }
  83   1      
  84   1          DDRAMAddress = position;
  85   1      
  86   1              while (str[i] !=0)
  87   1              {
  88   2                      if(DDRAMAddress == 8) lcd_setDDRAMAddress(0x40);
  89   2                  if(DDRAMAddress == 0x48)
  90   2                  {
  91   3                              lcd_setDDRAMAddress(0);
  92   3                              DDRAMAddress = 0;
  93   3                      }
  94   2      
  95   2                      DDRAMAddress ++;
  96   2                      lcd_WData(str[i]);
  97   2                      i ++;
  98   2              }
  99   1      }
 100          
 101          void lcd_init(void)
 102          {
 103   1              lcd_WCmd(0x38); //8 bit,2 line 5*7
 104   1              lcd_WCmd(0x0c); //
 105   1              lcd_WCmd(0x01); //clear display
 106   1              displayPosition = 0;
 107   1              DDRAMAddress = 0;
 108   1      }
 109          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    210    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2       3
C51 COMPILER V7.20   LCD                                                                   05/08/2005 16:32:09 PAGE 3   

   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 + -