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

📄 fun.lst

📁 lcd1602编程资料。包括8位和4位口的c语言程序。当单片机口不够时可用4位接法
💻 LST
字号:
C51 COMPILER V8.02   FUN                                                                   04/17/2007 16:42:04 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE FUN
OBJECT MODULE PLACED IN fun.OBJ
COMPILER INVOKED BY: E:\Program Files\Keil\C51\BIN\C51.EXE fun.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h>
   2          #include <intrins.h>
   3          #include "lcd1602.h"
   4          
   5           
   6          void delay (uchar times)                         //delay times ms
   7          {
   8   1        uchar i = 0;
   9   1        while (times --)
  10   1        {
  11   2          for (i = 0; i < 121; i++);
  12   2        }
  13   1      
  14   1      }
  15          
  16          bit bBusy()
  17          {
  18   1        bit result;
  19   1        RS = 0; RW = 1;      // read the AC and BF
  20   1        EN = 1;                          // generate a high level to read
  21   1      
  22   1        _nop_();
  23   1        _nop_();
  24   1        _nop_();
  25   1        _nop_();
  26   1      
  27   1        result = (bit)(P0 & 0x80);  //-----important---------
  28   1        EN = 0;
  29   1      
  30   1        return result;
  31   1      
  32   1      }
  33          
  34          void wr_byte(bit bcmd, uchar cmd)
  35          {
  36   1        while (bBusy());     // wait if the lcd is busy
  37   1      
  38   1        if (bcmd)                        // if it's  cmd, RS = 0;
  39   1          RS = 0;
  40   1        else                             // if it's data, RS = 1;
  41   1          RS = 1;
  42   1      
  43   1        RW = 0;                  // set  R/W = 0
  44   1      //  EN = 0;                        // this step is ignorable
  45   1      
  46   1        _nop_();
  47   1        _nop_();
  48   1        _nop_();
  49   1        _nop_();
  50   1      
  51   1        EN = 1;                               // set E = 1
  52   1        P0 = cmd;                     // prepare the valid data
  53   1      
  54   1        _nop_();
  55   1        _nop_();
C51 COMPILER V8.02   FUN                                                                   04/17/2007 16:42:04 PAGE 2   

  56   1        _nop_();
  57   1        _nop_();
  58   1      
  59   1        EN = 0;                               // set E = 0, generate a falling edge to write
  60   1        _nop_();
  61   1      
  62   1      }
  63          
  64          
  65          void ini_lcd1602(void)
  66          {
  67   1        delay (10);
  68   1        
  69   1      /* Function Set */
  70   1        wr_byte (1, 0x38);                            // 2 lines; 5*7 font
  71   1          
  72   1       /* --Display on/off-- */
  73   1        wr_byte (1, 0x0F);                            // Display: on; Cursor: on; Blink: on;
  74   1        
  75   1      /* --Display clear-- */
  76   1        wr_byte (1, 0x01);                            // display clear;
  77   1      
  78   1        
  79   1      /* --Entry mode set-- */           // I/D: incremental; SH: 0;
  80   1        wr_byte (1, 0x06);
  81   1      }
  82          
  83          void wr_byte_ram (bit bDDram, uchar addr, uchar ch)
  84          {
  85   1        if (bDDram)                             // write data to DDRAM
  86   1           wr_byte (1, addr | 0x80);
  87   1        else                                            // write data to CGRAM
  88   1           wr_byte (1, addr | 0x40);
  89   1      
  90   1        wr_byte (0, ch);              
  91   1      }
  92          
  93          void wr_length_ram (bit bDDram, uchar addr, uchar *pch, uchar len)
  94          {
  95   1        uchar i = 0;
  96   1      
  97   1        if (bDDram)                             // write data to DDRAM
  98   1          wr_byte (1, addr | 0x80);
  99   1        else                                            // write data to CGRAM
 100   1          wr_byte (1, addr | 0x40);
 101   1      
 102   1        for (; i < len; i++)
 103   1        {
 104   2          wr_byte (0, *pch);            // the AC will increase/decrease automatically
 105   2              pch ++;
 106   2        }
 107   1      
 108   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    199    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       8
   IDATA SIZE       =   ----    ----
C51 COMPILER V8.02   FUN                                                                   04/17/2007 16:42:04 PAGE 3   

   BIT SIZE         =   ----       4
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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