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

📄 lcd+test.lst

📁 基于51最小系统的LCD显示程序,包括电路图,源程序
💻 LST
字号:
C51 COMPILER V7.01  LCD_TEST                                                               08/18/2006 22:07:38 PAGE 1   


C51 COMPILER V7.01, COMPILATION OF MODULE LCD_TEST
OBJECT MODULE PLACED IN lcd+test.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE lcd+test.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*************************************************************
   2                  LCD1602 Drive Program
   3                  For 51 MCU
   4                                          by Donald
   5                                          2006-7-19
   6          **************************************************************/
   7          #include "reg52.h"
   8          
   9          #define         LINE1                                   0
  10          #define         LINE2                                   1
  11          #define         LINE1_HEAD                              0x80
  12          #define         LINE2_HEAD                              0xC0
  13          #define         LCD_DELAY_TIME                  40
  14          #define         DATA_MODE                               0x38
  15          #define         OPEN_SCREEN                             0x0C
  16          #define         DISPLAY_ADDRESS                 0x80
  17          #define         CLR                                             0x01
  18          #define         BUSY                                    0x80            //LCD Busy Tag
  19          
  20          #define         LCDIO                                   P2
  21          sbit            LCD1602_RS=P0^7;        //Data Command Pin              1 data          0 command       pin 4 
  22          sbit            LCD1602_RW=P0^6;        //Read Write Pin                1 read          0 write         pin 5
  23          sbit            LCD1602_EN=P0^5;        //LCD Enable Signal             pin 6
  24          
  25          /****************************************************************/
  26          void delay_5ms(void);                                                                                   //LCD Delay Function 
  27          void LCD_command(unsigned char command,unsigned char BusyC);    //write command function
  28          void LCD_data(unsigned char temp,unsigned char BusyC);                  //write data function
  29          void LCD_set_xy( unsigned char x, unsigned char y );                    //set display address function
  30          void LCD_write_char( unsigned x,unsigned char y,unsigned char dat);//write lcd a character function
  31          void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s);//write lcd string function
  32          void LCD_init(void);                                                                                    //lcd initize function
  33          unsigned char ReadStatus(void);
  34          
  35          void delay_400ms(void);                                                                                 //delay function
  36          
  37          /********************************************************************/
  38          void main(void)
  39          {
  40   1              LCD_init(); 
  41   1              while(1)                                
  42   1              {
  43   2                      LCD_command(CLR,0);
  44   2                      LCD_write_string(0,LINE1,"Wellcome to DUT");
  45   2                  LCD_write_string(0,LINE2,"www.dlut.edu.cn");
  46   2                     
  47   2                  delay_400ms();delay_400ms();
  48   2                  LCD_command(CLR,0);
  49   2                     
  50   2                  LCD_write_string(0,LINE1,"   LCD Test     ");
  51   2                  LCD_write_string(0,LINE2,"   Successful!  ");
  52   2                      
  53   2                  delay_400ms();delay_400ms();
  54   2      
  55   2                      LCD_command(CLR,0);
C51 COMPILER V7.01  LCD_TEST                                                               08/18/2006 22:07:38 PAGE 2   

  56   2      
  57   2                      LCD_write_string(0,LINE1,"  I'm Donald.   ");
  58   2                  LCD_write_string(0,LINE2,"   Thank You!   ");
  59   2      
  60   2                  delay_400ms(); delay_400ms();              
  61   2              }
  62   1      }
  63          //
  64          //
  65          //
  66          void delay_5ms(void)   
  67          {
  68   1              unsigned int i=5552;
  69   1              while(i--);
  70   1      }
  71          //
  72          //
  73          //
  74          void LCD_command(unsigned char command,unsigned char BusyC)
  75          {
  76   1              if (BusyC) ReadStatus(); //Test it busy or not
  77   1              LCDIO=command;
  78   1              LCD1602_RS=0;   
  79   1              LCD1602_RW=0;
  80   1              LCD1602_EN=0;
  81   1              LCD1602_EN=0;
  82   1              LCD1602_EN=1;
  83   1      }
  84          //
  85          //
  86          //
  87          void LCD_data(unsigned char dat,unsigned char BusyC)
  88          {
  89   1              if (BusyC) ReadStatus(); //Test it busy or not
  90   1              LCDIO=dat;
  91   1              LCD1602_RS=1;
  92   1              LCD1602_RW=0;
  93   1              LCD1602_EN=0;
  94   1              LCD1602_EN=0;
  95   1              LCD1602_EN=1;
  96   1      }
  97          //
  98          //
  99          //
 100          void LCD_set_xy( unsigned char x, unsigned char y )
 101          {
 102   1              unsigned char address;
 103   1              if (y == LINE1) 
 104   1                      address = LINE1_HEAD + x;
 105   1              else 
 106   1              address = LINE2_HEAD + x;
 107   1              LCD_command(address,1); 
 108   1      }
 109          //
 110          //
 111          //
 112          void LCD_write_char( unsigned x,unsigned char y,unsigned char dat)
 113          {
 114   1              LCD_set_xy( x, y ); 
 115   1              LCD_data(dat,1);
 116   1      }
 117          //
C51 COMPILER V7.01  LCD_TEST                                                               08/18/2006 22:07:38 PAGE 3   

 118          //
 119          //
 120          void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
 121          {
 122   1          LCD_set_xy( X, Y ); //set address 
 123   1          while (*s)  // write character
 124   1          {
 125   2              LCDIO=*s;
 126   2              LCD_data(*s);   
*** WARNING C209 IN LINE 126 OF LCD+TEST.C: '_LCD_data': too few actual parameters
 127   2              s ++;
 128   2          }
 129   1      }
 130          //
 131          //
 132          //
 133          void LCD_init(void)
 134          {
 135   1              delay_400ms();  
 136   1              LCD_command(CLR,0);//clear screen 
 137   1              LCD_command(DATA_MODE,1);//set 8 bit data transmission mode 
 138   1              LCD_command(OPEN_SCREEN,1);//open display (enable lcd display)
 139   1              LCD_command(DISPLAY_ADDRESS,1);//set lcd first display address 
 140   1              LCD_command(CLR,1);//clear screen
 141   1      }
 142          //
 143          //LCD Delay Function
 144          //
 145          void delay_400ms(void)      
 146          {
 147   1              unsigned char i = 5;
 148   1              unsigned int j;
 149   1              while(i--){
 150   2                      j=7269;
 151   2                      while(j--);
 152   2              };      
 153   1      }
 154          
 155          //
 156          //Read the LCD State
 157          //
 158          unsigned char ReadStatus(void)
 159          {
 160   1              LCDIO = 0xFF; 
 161   1              LCD1602_RS = 0;
 162   1              LCD1602_RW = 1;
 163   1              LCD1602_EN = 0;
 164   1              LCD1602_EN = 0;
 165   1              LCD1602_EN = 1;
 166   1              while (LCDIO & BUSY); //Test Busy State
 167   1              return(LCDIO);
 168   1      }
 169          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    314    ----
   CONSTANT SIZE    =    100    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       7
   IDATA SIZE       =   ----    ----
C51 COMPILER V7.01  LCD_TEST                                                               08/18/2006 22:07:38 PAGE 4   

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


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

⌨️ 快捷键说明

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