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

📄 clock.lst

📁 我做的畢業設計,用AT89S51 控制LCD1602作為顯示. DS1302時鐘芯片顯示時間,DS18B20測量溫度,還有4X4的鍵盤驅動.實現了一個計算功能.可以用PROTUES 仿真軟件仿真,當時
💻 LST
📖 第 1 页 / 共 3 页
字号:
 421   3            }
 422   2           break;
C51 COMPILER V7.50   CLOCK                                                                 04/09/2007 18:39:44 PAGE 8   

 423   2      case ALARM_ADJ_MIN_L:             //打玲时间分钟底位调整
 424   2            //display
 425   2                {
 426   3         
 427   3                
 428   3                                 if((Key_temp>=0)&&(Key_temp<=9))
 429   3                                  {
 430   4                        Alarm_Ram[MIN_L]=Key_temp+'0';GotoXY(8,1);LCD_send_data(Alarm_Ram[MIN_L]);
 431   4                                      }
 432   3                 GotoXY(8,1);
 433   3                 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
 434   3             GotoXY(8,1);
 435   3             Delay1ms(20);
 436   3                 BurstWrite1302_Flag=1;
 437   3            }
 438   2           break;
 439   2      case ALARM_ADJ_MIN_H:              //打玲时间分钟高位调整
 440   2            //display
 441   2                {
 442   3            
 443   3                 
 444   3                                 if((Key_temp>=0)&&(Key_temp<=5))
 445   3                                  {
 446   4                         Alarm_Ram[MIN_H]=Key_temp+'0';GotoXY(7,1);LCD_send_data(Alarm_Ram[MIN_H]);
 447   4                                      }
 448   3                 GotoXY(7,1);
 449   3                 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
 450   3             GotoXY(7,1);
 451   3             Delay1ms(20);
 452   3                 BurstWrite1302_Flag=1;
 453   3            }
 454   2           break;
 455   2      case ALARM_ADJ_HOUR_L:              //打玲时间小时底位调整  
 456   2            //display 
 457   2                {
 458   3          
 459   3                                 if((Key_temp>=0)&&(Key_temp<=9))
 460   3                                  {
 461   4                                       Alarm_Ram[HOUR_L]=Key_temp+'0';GotoXY(5,1);LCD_send_data(Alarm_Ram[HOUR_L]);
 462   4                                       }
 463   3                 GotoXY(5,1);
 464   3                 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
 465   3             GotoXY(5,1);
 466   3             Delay1ms(20);
 467   3                 BurstWrite1302_Flag=1;
 468   3            }
 469   2           break;
 470   2      case ALARM_ADJ_HOUR_H:             //打玲时间小时高位调整
 471   2            //display
 472   2                {
 473   3               if((Key_temp>=0)&&(Key_temp<=2))
 474   3                                  {
 475   4                                        Alarm_Ram[HOUR_H]=Key_temp+'0';GotoXY(4,1);LCD_send_data(Alarm_Ram[HOUR_H]);
 476   4                                      }
 477   3                 GotoXY(4,1);
 478   3                 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
 479   3             GotoXY(4,1);
 480   3             Delay1ms(20);
 481   3                 BurstWrite1302_Flag=1;
 482   3                 Bell_State_switch_flag=1;
 483   3            }
 484   2           break;
C51 COMPILER V7.50   CLOCK                                                                 04/09/2007 18:39:44 PAGE 9   

 485   2      case Bell_Enable_ON_OFF:         //打玲使能状态
 486   2           { if(Bell_State_switch_flag==1)
 487   3                  {
 488   4                      Bell_State_switch_flag=0;
 489   4                  LCD_send_command(LCD_CLEAR_SCREEN);
 490   4                  LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_OFF);//不显示光标
 491   4                  GotoXY(1,0);
 492   4                  Print("Eanble the Bell ");
 493   4                  }
 494   3             if(Key_temp==ZERO)
 495   3                   { 
 496   4                         Bell_Enable=~Bell_Enable;
 497   4                        } 
 498   3                if(Bell_Enable==1)
 499   3                       {
 500   4                        GotoXY(8,1);
 501   4                        Print("ON  ");
 502   4                   }
 503   3                else
 504   3                       {
 505   4                GotoXY(8,1);
 506   4                        Print("OFF");
 507   4                       }
 508   3             BurstWrite1302_Flag=1;
 509   3                Delay1ms(20);
 510   3                }
 511   2      default :break;
 512   2            }//end switch
 513   1              //}//end if
 514   1      
 515   1      
 516   1      
 517   1      }//end Clock
 518          
 519          
 520          void Display_Adjust_ALARM_Time(void)     //显示调整打玲时间
 521          {
 522   1       unsigned char code * p_string_code;
 523   1       p_string_code=string_input_the_alarm_time;
 524   1       LCD_disp_string_code(0,0,p_string_code);
 525   1       p_string_code=string_clear_line2;
 526   1       LCD_disp_string_code(0,1,p_string_code);
 527   1       GotoXY(4,1);
 528   1       Print(Alarm_Ram);
 529   1      }
 530          
 531          void BurstWrite1302_New(void)            //多字节时钟数据写入DS1302 
 532          {
 533   1       ClockRtc[0]=(((TimeString[6]-'0')<<4)&0x70)|(TimeString[7]-'0'&0x0f);
 534   1        ClockRtc[1]=(((TimeString[3]-'0')<<4)&0x70)|(TimeString[4]-'0'&0x0f);
 535   1         ClockRtc[2]=(((TimeString[0]-'0')<<4)&0x70)|(TimeString[1]-'0'&0x0f);
 536   1          ClockRtc[3]=(((DateString[6]-'0')<<4)&0x70)|(DateString[7]-'0'&0x0f);
 537   1               ClockRtc[4]=(((DateString[3]-'0')<<4)&0x70)|(DateString[4]-'0'&0x0f);
 538   1                ClockRtc[6]=(((DateString[0]-'0')<<4)&0x70)|(DateString[1]-'0'&0x0f);
 539   1               BurstWrite1302(ClockRtc);//写入新的时间数据
 540   1      DS1302_SetProtect(1);//关闭写入
 541   1      }
 542          
 543          
 544          /**************************************************************************
 545          定时器0 50MS 中断 实现功能
 546          1 读取DS1302 时钟数据
C51 COMPILER V7.50   CLOCK                                                                 04/09/2007 18:39:44 PAGE 10  

 547          2 控制蜂呜器响频率
 548          **************************************************************************/
 549          void  Time0(void) interrupt 1         
 550          {
 551   1       static unsigned char count_DS1302_R_time;
 552   1       TH0=(65536-50000)/256;
 553   1       TL0=(65536-50000)%256;
 554   1       count_DS1302_R_time++;
 555   1       if(count_DS1302_R_time>=5)
 556   1         {
 557   2          count_DS1302_R_time=0;
 558   2          DateToStr();
 559   2          GotoXY(6,0);
 560   2          Print(DateString);
 561   2          GotoXY(6,1);
 562   2          Print(TimeString);
 563   2         }
 564   1       if(LCD_LIGHT_FLAG==1)
 565   1        {
 566   2         if(count_50ms++==100)
 567   2          {
 568   3               LCD_LIGHT_FLAG=0;
 569   3           count_50ms=0;
 570   3           LCD_LIGHT=1;
 571   3           }
 572   2         }
 573   1        if(Bell_Enable==1)//(Bell_Enable==1)
 574   1            {
 575   2                 if((TimeString[HOUR_H]==Alarm_Ram[0])&&(TimeString[HOUR_L]==Alarm_Ram[1]))
 576   2                  {
 577   3                   if((TimeString[MIN_H]==Alarm_Ram[3])&&(TimeString[MIN_L]==Alarm_Ram[4]))
 578   3                    {
 579   4                     if((TimeString[SECOND_H]==Alarm_Ram[6])&&(TimeString[SECOND_L]==Alarm_Ram[7]))
 580   4                       {
 581   5                         Bell_Flag=1;
 582   5                           }
 583   4                     }
 584   3                   }
 585   2            }     
 586   1        if(Bell_Flag==1)
 587   1           {
 588   2             if((TimeString[MIN_H]>=Alarm_Ram[3])&&((TimeString[MIN_L]>=(Alarm_Ram[4]+1))))
 589   2               { 
 590   3                 Bell_Flag=0;
 591   3               }
 592   2             else
 593   2               { //Bell=0;
 594   3                   Bell_f++;
 595   3                   if(Bell_f==1||Bell_f==2)
 596   3                     Bell=0;
 597   3                   if(Bell_f==3)
 598   3                     Bell=1;
 599   3                   if(Bell_f==4||Bell_f==5)
 600   3                     Bell=0;
 601   3                   if(Bell_f==6||Bell_f==7||Bell_f==8||Bell_f==9)
 602   3                     Bell=1;
 603   3                   if(Bell_f==10||Bell_f==10)
 604   3                     {
 605   4                      Bell=0;
 606   4                     
 607   4                     }
 608   3                               if(Bell_f==12)
C51 COMPILER V7.50   CLOCK                                                                 04/09/2007 18:39:44 PAGE 11  

 609   3                                 {
 610   4                                    Bell=1;
 611   4                                        Bell_f=0;
 612   4                                 }
 613   3                } 
 614   2          }
 615   1        else
 616   1           {
 617   2             Bell=1;//close
 618   2           }
 619   1       
 620   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1841    ----
   CONSTANT SIZE    =     57    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     39       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      6    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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