C51 COMPILER V7.06   1602襙___鯻__允_                                                      04/25/2016 22:00:29 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE 1602襙___鯻__允_
OBJECT MODULE PLACED IN 1602液晶滚动显示.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 1602液晶滚动显示.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*-----------------------------------------------------------------------------
   2          程序功能：1602液晶滚动显示
   3          ------------------------------------------------------------------------------*/
   4          
   5          #include<reg52.h>
   6          #define uchar unsigned char
   7          #define uint unsigned int
   8          sbit rs=P3^5;     //位定义液晶数据命令选择端
   9          sbit wr=P3^6;     //位定义液晶读写选择端
  10          sbit leden=P3^4;  //位定义液晶使能端
  11          sbit dula=P2^6;   //数码管段选
  12          sbit wela=P2^7;   //数码管位选
  13          uint i,j;
  14          uchar num;
  15          uchar code table1[]="I LOVE YL-51 MCU";    //字符串用双引号刮起来，而不是单引号了
  16          uchar code table2[]="WELCOME TO YUNLONGDZ";
  17          void delay(uint x)  //延时
  18          {
  19   1              for(i=x;i>0;i--)
  20   1              {
  21   2              for(j=120;j>0;j--);
  22   2              }
  23   1      }
  24          
  25          void write_com(uchar com)   //写命令函数
  26          {
  27   1              rs=0;
  28   1              wr=0;
  29   1              leden=0;
  30   1              P0=com;
  31   1              leden=1;
  32   1              delay(5);
  33   1              leden=0;                
  34   1      }
  35          
  36          void write_data(uchar dat)   //写数据函数
  37          {
  38   1              rs=1;
  39   1              wr=0;
  40   1              leden=0;
  41   1              P0=dat;
  42   1              leden=1;
  43   1              delay(5);
  44   1              leden=0;                
  45   1      }
  46          
  47          void init()      //1602液晶初始化设置函数
  48          {
  49   1              write_com(0X38);
  50   1              write_com(0X08);
  51   1              write_com(0X01);
  52   1              write_com(0X06);
  53   1              write_com(0X0F);        
  54   1      }
  55          
C51 COMPILER V7.06   1602襙___鯻__允_                                                      04/25/2016 22:00:29 PAGE 2   

  56          void main()
  57          {
  58   1              P0=0;    //关闭数码管显示
  59   1              dula=0;
  60   1              wela=0;
  61   1              init();
  62   1              write_com(0X80+0X10);     //数据指针设置，在第一行的屏外第一格
  63   1              for(num=0;num<16;num++)   //写入I LOVE YL-51 MCU
  64   1              {
  65   2                      write_data(table1[num]);
  66   2                      delay(10);
  67   2              }
  68   1              write_com(0X80+0X50);    //数据指针设置，在第二行的屏外第一格
  69   1              for(num=0;num<20;num++)  //写入 WELCOME TO YUNLONGDZ
  70   1              {
  71   2                      write_data(table2[num]);
  72   2                      delay(10);
  73   2              }
  74   1              while(1)
  75   1              {
  76   2                      write_com(0x18);//整屏向左移动，若改为0x1C 是右移动
  77   2                      delay(500);
  78   2              }
  79   1      }
  80          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    191    ----
   CONSTANT SIZE    =     38    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      5    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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