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

📄 液晶时钟.lst

📁 1602液晶时钟
💻 LST
字号:
C51 COMPILER V7.06   襙__蔩钟                                                              04/09/2008 11:16:52 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE 襙__蔩钟
OBJECT MODULE PLACED IN 液晶时钟.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 液晶时钟.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<reg51.h>
   2          #define uchar unsigned  char
   3          #define uint unsigned int
   4          sbit rs=P3^5;
   5          sbit lcden=P3^4;
   6          sbit s1=P1^0;
   7          sbit s2=P1^1;
   8          sbit s3=P1^2;
   9          uchar count,count1;
  10          char shi,fen,miao;
  11          uchar table[]=" 2008-4-09 wen";
  12          uchar table1[]="   00:00:00";
  13          void keyscan();
  14          void delay(uint z)
  15          {       uchar i;
  16   1              for(;z>0;z--)
  17   1              for(i=0;i<110;i++);
  18   1      }
  19          
  20          void write_com(uchar com)
  21          {
  22   1              rs=0;
  23   1              lcden=0;
  24   1              P0=com;
  25   1              delay(5);
  26   1              lcden=1;
  27   1              delay(5);
  28   1              lcden=0;
  29   1      }
  30          void write_date(uchar date)
  31          {
  32   1              rs=1;
  33   1              lcden=0;
  34   1              P0=date;
  35   1              delay(5);
  36   1              lcden=1;
  37   1              delay(5);
  38   1              lcden=0;
  39   1      }
  40          void init()
  41          {
  42   1              uchar  num;
  43   1              
  44   1              lcden=0;
  45   1              delay(10);
  46   1              write_com(0x38);
  47   1              write_com(0x0C);
  48   1              write_com(0x06);
  49   1              write_com(0x01);
  50   1              write_com(0x80);
  51   1              for(num=0;num<15;num++)
  52   1                      {
  53   2                              write_date(table[num]);
  54   2                              delay(20);
  55   2                      }
C51 COMPILER V7.06   襙__蔩钟                                                              04/09/2008 11:16:52 PAGE 2   

  56   1              write_com(0x80+0x40);
  57   1              for(num=0;num<12;num++)
  58   1                      {
  59   2                              write_date(table1[num]);
  60   2                              delay(20);
  61   2                      }
  62   1              TMOD=0X01;
  63   1              TH0=(65536-50000)/256;
  64   1              TL0=(65536-50000)%256;
  65   1              EA=1;
  66   1              ET0=1;
  67   1              TR0=1;
  68   1      }
  69          
  70          write_sfm(uchar add,uchar date)
  71          {
  72   1              uchar sh,ge;
  73   1              sh=date/10;
  74   1              ge=date%10;
  75   1              write_com(0x80+0x40+add);
  76   1              write_date(sh+0x30);
  77   1              write_date(ge+0x30);
  78   1      }
  79          
  80          
  81          void main()
  82          {
  83   1              init();
  84   1              while(1)
  85   1                      {
  86   2                              keyscan();
  87   2                      }
  88   1      
  89   1      }
  90          
  91          void time0() interrupt 1
  92          {
  93   1              TH0=(65536-50000)/256;
  94   1              TL0=(65536-50000)%256;
  95   1              count++;
  96   1                      if(count==20)
  97   1                      {       
  98   2                              count=0;
  99   2                              miao++;
 100   2                              if(miao==60)
 101   2                              {
 102   3                                      miao=0;
 103   3                                      fen++;
 104   3                                      if(fen==60)
 105   3                                              {
 106   4                                                      fen=0;
 107   4                                                      shi++;
 108   4                                                      if(shi==24)
 109   4                                                              {
 110   5                                                                      shi=0;
 111   5                                                              }
 112   4                                                      write_sfm(3,shi);
 113   4                                              }
 114   3                                      write_sfm(6,fen);
 115   3                              }
 116   2      
 117   2                              write_sfm(9,miao);
C51 COMPILER V7.06   襙__蔩钟                                                              04/09/2008 11:16:52 PAGE 3   

 118   2                      }
 119   1      }
 120          
 121          void keyscan()
 122          {
 123   1              if(s1==0)
 124   1                      {
 125   2                              delay(10);
 126   2                              if(s1==0)
 127   2                              {
 128   3                                      count1++;
 129   3                                      while(!s1);
 130   3                                      if(count1==1)
 131   3                                              {
 132   4                                                      TR0=0;
 133   4                                                      write_com(0x80+0x40+9);
 134   4                                                      write_com(0x0f);
 135   4                                              }
 136   3                                      if(count1==2)
 137   3                                              {
 138   4                                                      write_com(0x80+0x40+6);
 139   4                                              }
 140   3                                      if(count1==3)
 141   3                                              {
 142   4                                                      write_com(0x80+0x40+3);
 143   4                                              }
 144   3                                      if(count1==4)
 145   3                                              {
 146   4                                                      count1=0;
 147   4                                                      TR0=1;
 148   4                                                      write_com(0x0c);
 149   4                                              }
 150   3      
 151   3                              }
 152   2                      }
 153   1                              
 154   1                              if(count1!=0)
 155   1                                      {
 156   2                                              if(s2==0)
 157   2                                                      {
 158   3                                                              delay(10);
 159   3                                                              if(s2==0)
 160   3                                                                      {
 161   4                                                                              while(!s2);
 162   4                                                                              if(count1==1)
 163   4                                                                                      {
 164   5                                                                                              miao++;
 165   5                                                                                              if(miao==60)
 166   5                                                                                                      miao=0;
 167   5                                                                                              write_sfm(9,miao);
 168   5                                                                                              write_com(0x80+0x40+9);
 169   5                                                                                      }
 170   4                                                                              if(count1==2)
 171   4                                                                                      {
 172   5                                                                                              fen++;
 173   5                                                                                              if(fen==60)
 174   5                                                                                                      fen=0;
 175   5                                                                                              write_sfm(6,fen);
 176   5                                                                                              write_com(0x80+0x40+6);
 177   5      
 178   5                                                                                      }
 179   4                                                                              if(count1==3)
C51 COMPILER V7.06   襙__蔩钟                                                              04/09/2008 11:16:52 PAGE 4   

 180   4                                                                                      {
 181   5                                                                                              shi++;
 182   5                                                                                              if(shi==24)
 183   5                                                                                                      shi=0;
 184   5                                                                                              write_sfm(3,shi);
 185   5                                                                                              write_com(0x80+0x40+3);
 186   5                                                                                      }
 187   4                                                                      }
 188   3                                                      }
 189   2                                              if(s3==0)
 190   2                                                      {
 191   3                                                              delay(10);
 192   3                                                              if(s3==0)
 193   3                                                                      {
 194   4                                                                              while(!s3);
 195   4                                                                              if(count1==1)
 196   4                                                                                      {
 197   5                                                                                              miao--;
 198   5                                                                                              if(miao==-1)
 199   5                                                                                                      miao=59;
 200   5                                                                                              write_sfm(9,miao);
 201   5                                                                                              write_com(0x80+0x40+9);
 202   5                                                                                      }
 203   4                                                                              if(count1==2)
 204   4                                                                                      {
 205   5                                                                                              fen--;
 206   5                                                                                              if(fen==-1)
 207   5                                                                                                      fen=59;
 208   5                                                                                              write_sfm(6,fen);
 209   5                                                                                              write_com(0x80+0x40+6);
 210   5                                                                                      }
 211   4                                                                              if(count1==3)
 212   4                                                                                      {
 213   5                                                                                              shi--;
 214   5                                                                                              if(shi==-1)
 215   5                                                                                                      shi=23;
 216   5                                                                                              write_sfm(3,shi);
 217   5                                                                                              write_com(0x80+0x40+3);
 218   5                                                                                      }
 219   4      
 220   4      
 221   4                                                                      }
 222   3                                                      }
 223   2      
 224   2      
 225   2      
 226   2                                      }
 227   1      
 228   1                      
 229   1      
 230   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    555    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     32    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.

C51 COMPILER V7.06   襙__蔩钟                                                              04/09/2008 11:16:52 PAGE 5   


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

⌨️ 快捷键说明

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