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

📄 lcd.lst

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

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    210    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2       3
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
C51 COMPILER V7.20   LCD                                                                   04/28/2005 16:17:13 PAGE 3   

END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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