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

📄 1602.lst

📁 LCD1602 液晶屏程序, 双行显示,无动画效果,keil编译通过
💻 LST
字号:
C51 COMPILER V7.50   1602                                                                  03/25/2008 17:22:54 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE 1602
OBJECT MODULE PLACED IN D:\TANG\1602\1602.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE D:\TANG\1602\1602.C DB SB OE

line level    source

   1          #include "reg51.h"
   2          /********************************************************************/
   3          //lcd part
   4          #define  LINE1     0
   5          #define  LINE2     1
   6          #define  LINE1_HEAD    0x80
   7          #define  LINE2_HEAD    0xC0
   8          #define  LCD_DELAY_TIME   40
   9          #define  DATA_MODE    0x38
  10          #define  OPEN_SCREEN    0x0C
  11          #define  DISPLAY_ADDRESS   0x80
  12          #define  CLEARSCREEN    LCD_en_command(0x01)
  13          //common part 
  14          #define  HIGH   1
  15          #define  LOW    0
  16          #define  TRUE    1
  17          #define  FALSE    0
  18          #define  ZERO    0 
  19          #define  MSB    0x80
  20          #define  LSB    0x01
  21          
  22          /*******************************************************************/
  23          //change this part at different board
  24          #define  LCDIO     P0
  25          sbit LCD1602_RS=P2^7;   //data command select  1 data  0 command  pin 4 
  26          sbit LCD1602_RW=P2^6;   //read write select   1 read   0 write     pin 5
  27          sbit LCD1602_EN=P2^5;   //LCD enable signal             pin 6
  28          
  29          /********************************************************************/
  30          void LCD_delay(void);//lcd delay function 
  31          void LCD_en_command(unsigned char command);//write command function
  32          void LCD_en_dat(unsigned char temp);//write data function
  33          void LCD_set_xy( unsigned char x, unsigned char y );//set display address function
  34          void LCD_write_char( unsigned x,unsigned char y,unsigned char dat);//write lcd a character function
  35          void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s);//write lcd string function
  36          void LCD_init(void);//lcd initize function
  37          
  38          /********************************************************************/
  39          void delay_nms(unsigned int n);//delay function
  40          
  41          /********************************************************************/
  42          
  43          /********************************************************************/
  44          /******************** LCD PART *************************************/
  45          void LCD_delay(void)   
  46          {
  47   1       unsigned char i;
  48   1       for(i=LCD_DELAY_TIME;i>ZERO;i--)//be sure lcd reset
  49   1         ;
  50   1      }
  51          /********************************************************************/  
  52          void LCD_en_command(unsigned char command)
  53          {
  54   1       LCDIO=command;
  55   1       LCD1602_RS=LOW;   
C51 COMPILER V7.50   1602                                                                  03/25/2008 17:22:54 PAGE 2   

  56   1       LCD1602_RW=LOW;
  57   1       LCD1602_EN=LOW;
  58   1       LCD_delay();
  59   1       LCD1602_EN=HIGH;
  60   1      }
  61          /********************************************************************/
  62          void LCD_en_dat(unsigned char dat)
  63          {
  64   1       LCDIO=dat;
  65   1       LCD1602_RS=HIGH;
  66   1       LCD1602_RW=LOW;
  67   1       LCD1602_EN=LOW;
  68   1       LCD_delay();
  69   1       LCD1602_EN=HIGH;
  70   1      }
  71          /********************************************************************/
  72          void LCD_set_xy( unsigned char x, unsigned char y )
  73          {
  74   1       unsigned char address;
  75   1       if (y == LINE1) 
  76   1        address = LINE1_HEAD + x;
  77   1       else 
  78   1           address = LINE2_HEAD + x;
  79   1       LCD_en_command(address); 
  80   1      }
  81          /********************************************************************/
  82          void LCD_write_char( unsigned x,unsigned char y,unsigned char dat)
  83          {
  84   1       LCD_set_xy( x, y ); 
  85   1       LCD_en_dat(dat);
  86   1      }
  87          /********************************************************************/
  88          void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
  89          {
  90   1          LCD_set_xy( X, Y ); //set address 
  91   1          while (*s)  // write character
  92   1          {
  93   2           LCDIO=*s;
  94   2              LCD_en_dat(*s);   
  95   2       s ++;
  96   2          }
  97   1      }
  98          /********************************************************************/
  99          void LCD_init(void)
 100          { 
 101   1       CLEARSCREEN;//clear screen 
 102   1       LCD_en_command(DATA_MODE);//set 8 bit data transmission mode 
 103   1       LCD_en_command(OPEN_SCREEN);//open display (enable lcd display)
 104   1       LCD_en_command(DISPLAY_ADDRESS);//set lcd first display address 
 105   1       CLEARSCREEN;//clear screen
 106   1      }
 107          /********************************************************************/
 108          /*********************** OTHER PART *********************************/
 109          void delay_nms(unsigned int n)      
 110          {
 111   1          unsigned int i=0,j=0;
 112   1          for (i=n;i>0;i--)
 113   1           for (j=0;j<1140;j++);  
 114   1      }
 115          /********************************************************************/
C51 COMPILER V7.50   1602                                                                  03/25/2008 17:22:54 PAGE 3   

NAME                                    CLASS   MSPACE  TYPE    OFFSET  SIZE
====                                    =====   ======  ====    ======  ====


P0 . . . . . . . . . . . . . . . . . .  SFR      DATA   U_CHAR   0080H  1
P2 . . . . . . . . . . . . . . . . . .  SFR      DATA   U_CHAR   00A0H  1
_LCD_en_dat. . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  dat. . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0007H  1
LCD1602_EN . . . . . . . . . . . . . .  ABSBIT   -----  BIT      00A5H  1
_delay_nms . . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  n. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_INT    0006H  2
  i. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_INT    0004H  2
  j. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_INT    0002H  2
LCD1602_RS . . . . . . . . . . . . . .  ABSBIT   -----  BIT      00A7H  1
LCD1602_RW . . . . . . . . . . . . . .  ABSBIT   -----  BIT      00A6H  1
_LCD_en_command. . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  command. . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0007H  1
_LCD_set_xy. . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  x. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0007H  1
  y. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0005H  1
  address. . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0006H  1
_LCD_write_string. . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  X. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0007H  1
  Y. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0005H  1
  s. . . . . . . . . . . . . . . . . .  * REG *  DATA   PTR      0001H  3
_LCD_write_char. . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  x. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_INT    0082H  2
  y. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0005H  1
  dat. . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0004H  1
LCD_delay. . . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
  i. . . . . . . . . . . . . . . . . .  * REG *  DATA   U_CHAR   0007H  1
LCD_init . . . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    145    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   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 + -