C51 COMPILER V8.08   DS1602                                                                08/19/2015 12:54:25 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE DS1602
OBJECT MODULE PLACED IN ds1602.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE DS1602\ds1602.c BROWSE DEBUG OBJECTEXTEND PRINT(.\ds1602.lst) OBJECT(ds1602
                    -.obj)

line level    source

   1          #include "reg52.h"      /*包含STC单片机头文件*/
   2          #include "QX51/qx51.h" /*包含qx51开发板头文件*/
   3          #include "DELAY/delay.h"/*包含delay延时函数文件*/
   4          #include "ds1602.h"
   5          
   6          uchar datstr[]="123456789ABCDEF";
   7          uchar datnum[]= {10,20,0x10,0x10,0x01};
   8          uchar str[4];//uchartostr函数转换的字符串 同时可以把16进制转成10进制
   9          
  10          void write_com(uchar com)  //写命令
  11          {
  12   1              P0=com;
  13   1              rs=0;
  14   1              LCDEN=0;
  15   1              delay_ms(5);
  16   1              LCDEN=1;
  17   1              delay_ms(5);
  18   1              LCDEN=0;
  19   1                      
  20   1      }
  21          void write_data(uchar date)       //写数据
  22          {
  23   1              P0=date;
  24   1              rs=1;
  25   1              LCDEN=0;
  26   1              delay_ms(5);
  27   1              LCDEN=1;
  28   1              delay_ms(5);
  29   1              LCDEN=0;
  30   1                      
  31   1      }
  32          void init_1602()
  33          {
  34   1          rw=0;
  35   1              write_com(0x38);   //显示模式设置：16×2显示，5×7点阵，8位数据接口
  36   1              delay_ms(5);
  37   1              write_com(0x0c);   //显示模式设置
  38   1              delay_ms(5);
  39   1              write_com(0x06);   //显示模式设置：光标右移，字符不移
  40   1              delay_ms(5);
  41   1              write_com(0x01);   //清屏幕指令，将以前的显示内容清除
  42   1              delay_ms(5);    
  43   1      }
  44          
  45          uchar *uchartostr(uchar num)    //将一个字节的数据转换为字符串 或10进制
  46          {
  47   1              uchar x2,x1,x0,i;
  48   1              x2=num/100;
  49   1              x1=num%100/10;
  50   1              x0=num%100%10;
  51   1              i=0;
  52   1              if(x2!=0)
  53   1              {
  54   2                      str[i]=x2+48;
C51 COMPILER V8.08   DS1602                                                                08/19/2015 12:54:25 PAGE 2   

  55   2                      i++;
  56   2              }
  57   1              if(x1!=0)
  58   1              {
  59   2                      str[i]=x1+48;
  60   2                      i++;
  61   2              }
  62   1              str[i]=x0+48;
  63   1              i++;
  64   1              str[i]='\0';
  65   1              return str;
  66   1      }
  67          
  68          void lcd_dis(uchar X,uchar Y,uchar *dis)        //显示数据数组
  69          {                          
  70   1         uchar  pos;
  71   1              switch(X)
  72   1              {
  73   2                      case 0:X=0x00;
  74   2                      break;
  75   2                      case 1:X=0x40;
  76   2                      break;
  77   2                      break;
  78   2                      default:break;
  79   2              }
  80   1      
  81   1         pos =0x80+X+Y;  
  82   1         write_com(pos);     //显示地址
  83   1         while(*dis!='\0')
  84   1         {
  85   2              write_data(*dis++);             
  86   2         }
  87   1      }
  88          
  89          void lcd_distostr(uchar X,uchar Y,uchar dis)//显示字符串 数组
  90          {                          
  91   1         uchar  pos,i;
  92   1         i=dis; //设定从数组中的第几个字符串开始显示
  93   1              switch(X)
  94   1              {
  95   2                      case 0:X=0x00;
  96   2                      break;
  97   2                      case 1:X=0x40;
  98   2                      break;
  99   2                      break;
 100   2                      default:break;
 101   2              }
 102   1      
 103   1         pos =0x80+X+Y;  
 104   1         write_com(pos);     //显示地址
 105   1              while(datstr[i] !='\0' )
 106   1              {
 107   2                      write_data(datstr[i]);
 108   2                      i++;
 109   2              }
 110   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    275    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
C51 COMPILER V8.08   DS1602                                                                08/19/2015 12:54:25 PAGE 3   

   PDATA SIZE       =   ----    ----
   DATA SIZE        =     25       4
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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