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

📄 timer.lst

📁 基于89S52的电子时钟
💻 LST
字号:
C51 COMPILER V7.06   TIMER                                                                 06/08/2006 23:56:17 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE TIMER
OBJECT MODULE PLACED IN timer.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE timer.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          #include "timer.h"
   3          #include "main.h"
   4          #include "1602.h"
   5          #include "KEYS.h"
   6          unsigned char time_1s_ok=0;
   7          unsigned int year;
   8          volatile unsigned char week=2,second,minute=0,hour,day=6,month=6;  //分别保存秒、分、时、天、月、年的变量
   9          unsigned char counter_50ms=0;             //保存多少个50毫秒的变量
  10          unsigned char days_of_month;            //保存该月多少天的变量
  11          
  12          void Count_1_interrup(void) interrupt 3     //定时器0中断处理函数
  13          {
  14   1       EA=1; //允许定时器0中断
  15   1      TL1=0xF0;
  16   1      TH1=0xD8;
  17   1      ScanKey();  
  18   1      }
  19          void timer0_isr(void) interrupt 1 using 1      //定时器0中断处理函数
  20          {
  21   1       TL0=0xB9;
  22   1       TH0=0x40;                             //定时器重装。定时50mS中断一次 
  23   1       if(++counter_50ms>=20)                  //1秒到
  24   1        {
  25   2         time_1s_ok=1;
  26   2         counter_50ms=0;                     //清50毫秒计数
  27   2         second++;                           //秒加1
  28   2         if(second==60)                      //如果秒到60
  29   2          {
  30   3           second=0;                         //秒清0
  31   3           minute++; 
  32   3           //分加1
  33   3           if(minute==60)                    //如果分到60
  34   3            {
  35   4             minute=0;                       //分清0
  36   4             hour++;                         //小时加1           
  37   4             if(hour==24)                    //如果小时到24
  38   4              {
  39   5               hour=0;                       //小时清零
  40   5               week++;
  41   5                       if(week>7)
  42   5                       week=1;        
  43   5                switch(month)
  44   5             {
  45   6             case 1:
  46   6              case 3:
  47   6               case 5:
  48   6                case 7:
  49   6                  case 8:
  50   6                   case 10:
  51   6                     case 12:if(++day>31)
  52   6                      {
  53   7                       day=1;   
  54   7                      if((++month>12)||(month==0))
  55   7                                 {
C51 COMPILER V7.06   TIMER                                                                 06/08/2006 23:56:17 PAGE 2   

  56   8                                   month=1;
  57   8                                    ++year;
  58   8                                  }
  59   7                                      }
  60   6                                      break;
  61   6            case 4:
  62   6             case 6:
  63   6              case 9:
  64   6                case 11:if(++day>30)
  65   6                {
  66   7                 day=1;   
  67   7                 if((++month>12)||(month==0))
  68   7                      {
  69   8                      month=1;
  70   8                      ++year;
  71   8                      }
  72   7                              }
  73   6                              break;
  74   6              case 2:
  75   6               if(((year%4)==0)&&((year%100)!=0))
  76   6                   {
  77   7                   if(++day>29)
  78   7                {
  79   8                 day=1;   
  80   8                 if((++month>12)||(month==0))
  81   8                      {
  82   9                      month=1;
  83   9                      ++year;
  84   9                      }
  85   8                              }
  86   7                        }
  87   6              else 
  88   6               {
  89   7                 if(++day>28)
  90   7                 {
  91   8                 day=1;   
  92   8                 if((++month>12)||(month==0))
  93   8                      {
  94   9                      month=1;
  95   9                      ++year;
  96   9                      }
  97   8                 }
  98   7               }
  99   6                 break;
 100   6             default:break;
 101   6             }                 //天置1          
 102   5              }
 103   4              }
 104   3            }
 105   2          }
 106   1        } 
 107          
 108          
 109          void display_time(void)
 110          {
 111   1      WriteCommandLCM(0x80,0);
 112   1      LCD_printc(year/1000%10+48);
 113   1      LCD_printc(year/100%10+48);
 114   1      LCD_printc(year/10%10+48);
 115   1      LCD_printc(year%10+48);
 116   1      
 117   1      LCD_printc('-');
C51 COMPILER V7.06   TIMER                                                                 06/08/2006 23:56:17 PAGE 3   

 118   1      
 119   1      LCD_printc(month/10%10+48);
 120   1      LCD_printc(month%10+48);
 121   1      
 122   1      LCD_printc('-');
 123   1      
 124   1      LCD_printc(day/10%10+48);
 125   1      LCD_printc(day%10+48);
 126   1      WriteCommandLCM(0x8c,1);
 127   1      switch(week)
 128   1      {
 129   2      case 1:LCD_prints("Mon.");break;
 130   2      case 2:LCD_prints("Tue.");break;
 131   2      case 3:LCD_prints("Wed.");break;
 132   2      case 4:LCD_prints("Thu.");break;
 133   2      case 5:LCD_prints("Fri.");break;
 134   2      case 6:LCD_prints("Sat.");break;
 135   2      case 7:LCD_prints("Sun.");break;
 136   2      default:break;
 137   2      }
 138   1      WriteCommandLCM(0x80+0x40,1);
 139   1      LCD_printc(' ');//用来清除闹钟标识
 140   1      LCD_printc(' ');
 141   1      
 142   1      LCD_printc(hour/10%10+48);
 143   1      LCD_printc(hour%10+48);
 144   1      
 145   1      LCD_printc(':');
 146   1      
 147   1      LCD_printc(minute/10%10+48);
 148   1      LCD_printc(minute%10+48);
 149   1      
 150   1      LCD_printc(':');
 151   1      
 152   1      LCD_printc(second/10%10+48);
 153   1      LCD_printc(second%10+48);
 154   1      }


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