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

📄 retime.lst

📁 单片机设计--关于2008奥运会的代码及仿真
💻 LST
📖 第 1 页 / 共 4 页
字号:
 728   1          year_unitstore2=year_unitstore;       //保存年各位数据
 729   1          year_decastore2=year_decastore;
 730   1          year_hundstore2=year_hundstore;
 731   1          year_thoustore2=year_thoustore;
 732   1          year_jointed=year_unitstore;
 733   1          year_decastore=year_decastore<<4;
 734   1          year_decastore=year_decastore&0xf0;
 735   1          year_jointed=year_jointed+year_decastore;       //得到年的抵8位
 736   1          year_jointed=year_jointed<<8;               //将年的低8和高8互换
C51 COMPILER V8.02   RETIME                                                                06/24/2007 13:22:44 PAGE 13  

 737   1          year_jointed=year_jointed+year_hundstore;
 738   1          year_thoustore=year_thoustore<<4;
 739   1          year_thoustore=year_thoustore&0xf0;
 740   1          year_jointed=year_jointed+year_thoustore;   //得到年,需将其进行高8与低8互换
 741   1          year_help1=year_jointed&0xff00;
 742   1          year_help1=year_help1>>8;                   //得到年低8位
 743   1          year_help2=year_jointed&0x00ff;
 744   1          year_help2=year_help2<<8;                   //得到年高8位
 745   1          year_jointed=year_help1+year_help2;         // 得到年位
 746   1          year_unitstore=year_unitstore2;
 747   1          year_decastore=year_decastore2;
 748   1          year_hundstore=year_hundstore2;
 749   1          year_thoustore=year_thoustore2;             //弹出年各位数据
 750   1      }
 751          
 752          /*******************************
 753          定时器0中断子程序
 754          ********************************/
 755          void timer0(void) interrupt 1 using 1
 756          {
 757   1          TH0=0x3c;
 758   1          TL0=0xb0;
 759   1          if((++time_num)==20)
 760   1              {
 761   2                  time_num=0;
 762   2                  ++miao_ge;   //定时一秒到,秒个位加一
 763   2              }
 764   1      }               
 765          /******************************
 766           当秒个位加到9时进一,
 767          ……
 768          *******************************/    
 769          void dis_dingshi(void)  
 770          {   
 771   1          if(miao_ge==10)                     
 772   1          {
 773   2              miao_ge=0;
 774   2              if((++miao_shi)==6)             
 775   2              {       
 776   3                  miao_shi=0;
 777   3                  if((++fen_ge)==10)          
 778   3                      {
 779   4                      fen_ge=0;
 780   4                      if((++fen_shi)==6)
 781   4                              {
 782   5                              fen_shi=0;
 783   5                          if((--shi_num)!=0)
 784   5                                      {
 785   6                              if((++shi_ge)==10)
 786   6                                              {
 787   7                                              shi_ge=0;
 788   7                                      ++shi_shi;
 789   7                                              }
 790   6                                      }
 791   5                          else if(shi_num==0)
 792   5                                      {
 793   6                              shi_num=24;
 794   6                                      shi_ge=0;
 795   6                                      shi_shi=0;
 796   6                                  if(retime_unit==0&retime_decade==0&retime_hundred==0&retime_thousand==0)//倒计
             -时减一
 797   6                                                      {
C51 COMPILER V8.02   RETIME                                                                06/24/2007 13:22:44 PAGE 14  

 798   7                                                      ;
 799   7                                                      }
 800   6                                              else 
 801   6                                                      {
 802   7                                       if((--retime_unit)==10)
 803   7                                                       {
 804   8                                              retime_unit=0;
 805   8                                          if((--retime_decade)==10)
 806   8                                                              {
 807   9                                                      retime_decade=0;
 808   9                                              if((--retime_hundred)==10)
 809   9                                                                      {
 810  10                                                              retime_hundred=0;
 811  10                                                      if((--retime_thousand)==10)
 812  10                                                                              {
 813  11                                                                      retime_thousand=0;
 814  11                                                                              }
 815  10                                                                      }
 816   9                                                              }
 817   8                                                       }
 818   7                                                      }
 819   6      
 820   6                              if((month_unit|0xfe)==0xff)     //是奇数月,日为31天
 821   6                                              {       
 822   7                                          if((--day_numj)!=0)                 //31天没到
 823   7                                                          {   
 824   8                                                      if((++day_unit)==10)
 825   8                                                                      {
 826   9                                                                      day_unit=0;
 827   9                                                                      ++day_decade;
 828   9                                                                      }
 829   8                                                              }
 830   7                                          else if(day_numj==0)                        //31天到了
 831   7                                                              {
 832   8                                                      day_numj=31;
 833   8                                                              day_unit=1;
 834   8                                                      day_decade=0;
 835   8                                                                      
 836   8                                              if((--month_num)!=0)             //12个月没到
 837   8                                                                      {       
 838   9                                                              if((++month_unit)==10)
 839   9                                                                                      {
 840  10                                                                              month_unit=0;
 841  10                                                                              ++month_decade;
 842  10                                                                                      }
 843   9                                                                      }
 844   8                                              else if(month_num==0)    //12个月到了
 845   8                                                                      {
 846   9                                                                      month_num=12;
 847   9                                                                      month_unit=1;
 848   9                                                              month_decade=0;
 849   9                                                  if((++year_unit)==10)       //年个位是否到9
 850   9                                                                              {
 851  10                                                                      year_unit=0;
 852  10                                                              if((++year_decade)==10)
 853  10                                                                                      {
 854  11                                                                              year_decade=0;
 855  11                                                                      if((++year_hundred)==10)
 856  11                                                                                              {
 857  12                                                                                      year_hundred=0;
 858  12                                                              if((++year_thousand)==10)year_thousand=0;
 859  12                                                                                              }
C51 COMPILER V8.02   RETIME                                                                06/24/2007 13:22:44 PAGE 15  

 860  11                                                                                      }
 861  10                                                                              }
 862   9                                                                      }
 863   8                                                              }
 864   7                                              }
 865   6                              else if((month_unit|0xfe)!=0xff)    //是偶数月,日为30天
 866   6                                              {
 867   7                                  if((--day_numo)!=0)                 //30天没到
 868   7                                              {       
 869   8                                      if((++day_unit)==10)
 870   8                                                      {
 871   9                                                      day_unit=0;
 872   9                                                      ++day_decade;
 873   9                                                      }
 874   8                                                      }
 875   7                                  else if(day_numo==0)                        //30天到了
 876   7                                                      {
 877   8                                      if(month_unit==2)
 878   8                                                      {       
 879   9                                              if(day_numoo==28)
 880   9                                                              {       
 881  10                                                              day_numo=28;
 882  10                                                              day_unit=1;
 883  10                                                              day_decade=0;
 884  10                                                              }
 885   9                                              else if(day_numoo==29)
 886   9                                                              {
 887  10                                                              day_numo=29;
 888  10                                                              day_unit=1;
 889  10                                                              day_decade=0;
 890  10                                                              }
 891   9                                                      }                       
 892   8                                                      else 
 893   8                                                      {       
 894   9                                                      day_numj=30;
 895   9                                                      day_unit=1;
 896   9                                              day_decade=0;
 897   9                                                      }
 898   8                                     if((--month_num)!=0)              //12个月没到
 899   8                                                 {    
 900   9                                              if((++month_unit)==10)
 901   9                                                              {
 902  10                                                              month_unit=0;
 903  10                                                      ++month_decade;
 904  10                                                              }
 905   9                                                      }
 906   8                                      else if(month_num==0)    //12个月到了
 907   8                                                      {
 908   9                                                      month_num=12;
 909   9                                                      month_unit=1;
 910   9                                                      month_decade=0;
 911   9                                          if((++year_unit)==10)       //年个位是否到9
 912   9                                                              {
 913  10                                                               year_unit=0;
 914  10                                               if((++year_decade)==10)
 915  10                                                                       {
 916  11                                                              year_decade=0;
 917  11      
 918  11                                                      if((++year_hundred)==10)
 919  11                                                                              {
 920  12                                                                      year_hundred=0;
 921  12                                                      if((++year_thousand)==10)year_thousand=0;
C51 COMPILER V8.02   RETIME                                                                06/24/2007 13:22:44 PAGE 16  

 922  12                                                                              }
 923  11                                                                       }
 924  10                                                              }
 925   9                                                      }
 926   8                                                      }
 927   7                                              }
 928   6                                      }
 929   5                              }
 930   4                      }
 931   3              }
 932   2          }
 933   1      }   
 934          /*************主程序**************/
 935          void main(void)
 936          {  
 937   1          TMOD=0x01;
 938   1          TH0=0x3c;
 939   1          TL0=0xb0;
 940   1          EA=1;
 941   1          ET0=1;
 942   1          TR0=1;
 943   1          while(1)
 944   1          {   
 945   2              kbscan();       //调按键扫描
 946   2              display();      //六个数码管显示
 947   2              hour_flash();   //调小时位闪烁
 948   2              min_flash();    //调分钟位闪烁
 949   2              year_flash();   //年闪烁
 950   2              month_flash();  //月闪烁
 951   2              day_flash();    //日闪烁
 952   2              retime_flash();
 953   2              dis_dingshi();  //到一秒加一,到一分加一,到一小时加一,到24点清零
 954   2          }
 955   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2340    ----
   CONSTANT SIZE    =     22    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     52       6
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      7    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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