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

📄 lcd1602.lst

📁 利用单片制作信号发生器
💻 LST
字号:
C51 COMPILER V7.50   LCD1602                                                               08/15/2007 19:26:19 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE LCD1602
OBJECT MODULE PLACED IN LCD1602.OBJ
COMPILER INVOKED BY: D:\软件\单片机\keil c51\keil 软件\C51\BIN\C51.EXE LCD1602.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          
   2          #include <reg51.h>
   3          #include "hardware.h"
   4          #include "LCD1602.h"
   5          
   6          
   7          
   8          
   9          void mdelay(unsigned int);
  10          
  11          //char code line1[] = "024680 6 8 0 2 4";
  12          //char code line2[] = "hjllprtvvvvxxxxx";
  13          //char code rect_line1[16];//format : F# DR:2/3#XXXXHZ
  14          //char code rect_line2[] = "duty ratio 5H 6L";
  15          //char code sin_line1[16] = "Z 0.5-5.0v0000HZ";
  16          //char code sin_line2[16] = "5 crest 6 trough";
  17          
  18          void LCD_write_cmd(unsigned char cmd)
  19          {
  20   1              LCD_data_port = cmd;
  21   1              LCD_RS = 0;
  22   1              LCD_RW = 0;
  23   1              LCD_E = 1;
  24   1              mdelay(1);
  25   1              LCD_E = 0;
  26   1      }
  27          
  28          void LCD_write_data(unsigned char row, unsigned char cow, const char Data) reentrant
  29          {
  30   1              unsigned char addr = 0;
  31   1              row = row & 0x1;
  32   1              cow = cow & 0xf;
  33   1              if (row) 
  34   1                      addr = (0x80 | cow) + 0x40;
  35   1          else addr = 0x80 | cow;
  36   1              LCD_write_cmd(addr);
  37   1              
  38   1              LCD_data_port = Data;
  39   1              LCD_RS = 1;
  40   1              LCD_RW = 0;
  41   1              LCD_E = 1;
  42   1              mdelay(1);
  43   1              LCD_E = 0;
  44   1      }
  45          
  46          void mdelay(unsigned int msec)
  47          {
  48   1              int i = 0;
  49   1              while (msec--) 
  50   1                      for (i = 0; i <= 500; i++);
  51   1      }
  52          
  53          void init_LCD1602()
  54          {
  55   1              mdelay(20);
C51 COMPILER V7.50   LCD1602                                                               08/15/2007 19:26:19 PAGE 2   

  56   1              LCD_write_cmd(0x38);//8 bites trans, 2 lines, 5*7, 
  57   1              LCD_write_cmd(0x8);//close display
  58   1              LCD_write_cmd(0x6);//cursor right shift, AC inc,  no ALL_SHIFT
  59   1              LCD_write_cmd(0x2);//cursor and ac addr reset
  60   1              LCD_write_cmd(0x1);//清屏
  61   1              LCD_write_cmd(0xc);//open display,  no cursor ,  no cursor flash
  62   1      }
  63          
  64          
  65          void printstr(unsigned char start, unsigned char end, const char *str)
  66          {
  67   1              unsigned char count = end -start +1;
  68   1              unsigned char index = 0;
  69   1              do {
  70   2                      LCD_write_cmd(0x80 | start);
  71   2              //      #pragma asm
  72   2              //              MOV     P2, str[index];
  73   2              //      #pragma asmend
  74   2                      if (start > 0x40)
  75   2                              LCD_write_data(1, start + index - 0x40, str[index]);
  76   2                      else LCD_write_data(0, start + index , str[index]);
  77   2                      index++;
  78   2              } while (index < count);
  79   1      }
  80                  
  81                                          
  82          /*void LCD_check_busy()
  83          {
  84                  //不知道怎么实现,E 的时序图
  85          }       
  86          */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    267    ----
   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 + -