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

📄 text1.lst

📁 自己在keil51中用C实现了一个电子钢琴展览项目
💻 LST
📖 第 1 页 / 共 2 页
字号:
 342   1      RCAP2L=0xdC;    
 343   1      T2CON=0x34;     //
 344   1      PCON = 0x00;//SMOD=0;
 345   1      SCON = 0x50;//串行口于模式1,8位UART
 346   1      IE = 0x92;//turn on EA,ES,ET0,EC
 347   1      EBO=1;
 348   1      IP=0x10;
 349   1      CMOD=0x00;//PCA允许中断                                                     
 350   1      CCAPM0=0x00;
 351   1      CCAPM1=0x00;
 352   1      CCAPM2=0x00;
 353   1      CCAPM3=0x00;
 354   1      CCAPM4=0x00;
 355   1      CCF1=0;
 356   1      CCF2=0;
 357   1      CCF3=0;
 358   1      CCF4=0;
 359   1         
 360   1      receive_status =0;//一串数据接收成功标志 1-成功
 361   1      send_status =0;
 362   1      send_num=1;
 363   1      play_1=1;
 364   1      play_2=1;
 365   1      smog_hand=1;
C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 7   

 366   1      CO=1;
 367   1      start=1;
 368   1      sr_flag=0;
 369   1      play1_flag=0;
 370   1      play2_flag=0;
 371   1      KJOK=1;
 372   1      CO_flag=1;
 373   1      start_flag=1;
 374   1      auto_flag=1;
 375   1      start_flag=1;
 376   1      start_flag1=0;
 377   1      sh_flag=0;
 378   1      pause=0;
 379   1      con=0;
 380   1      receive_len=0;
 381   1      GJOK=1;
 382   1      pp=1;
 383   1      qmend=0;
 384   1      i=0;
 385   1      qu[0]=0;
 386   1      qu[1]=0;
 387   1      qu[2]=0;
 388   1      
 389   1      
 390   1      while(1)
 391   1      {  
 392   2       SDA=1;
 393   2       SDA=0;
 394   2       
 395   2      //关机
 396   2      if((CO==0&&sr_flag==0&&play_1==1&&play_2==1&&KJOK==0)||CO1==0)
 397   2      {  delay();
 398   3         delay();
 399   3         delay();
 400   3      if((CO==0&&sr_flag==0&&play_1==1&&play_2==1)||CO1==0)
 401   3       { sr_flag=1;
 402   4         send_buf[0] =0x71;
 403   4         send_buf[1] ='C';
 404   4         send_buf[2] ='O';
 405   4         send_buf[3] =',';
 406   4         send_buf[4] =0;
 407   4         send_buf[5] =0x23;
 408   4         send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5])%0x100);    
 409   4         send_buf[6] =send_check;
 410   4         send_buf[7] =0x0d;
 411   4         send_status =0;
 412   4         SBUF=send_buf[0];
 413   4         time_s_gj=0;
 414   4         CO_flag=0; 
 415   4         GJOK=0;
 416   4         EC=0;
 417   4         start_flag=1;
 418   4         enable=0;
 419   4        }
 420   3      }
 421   2      if(CO==1||play_1==0||play_2==0)
 422   2      {sr_flag=0;}
 423   2      
 424   2      //延时10分钟关机 
 425   2      
 426   2      if(time_s_gj>=60&&CO_flag==0)
 427   2       { shutdown_s=0;
C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 8   

 428   3         shutdown_c=0;
 429   3         shutdown_f=0;                   
 430   3         shutdown=0; 
 431   3         CO_flag=1;
 432   3          } 
 433   2      
 434   2      //开机
 435   2       if(start==0&&start_flag1==0)
 436   2         { CO_flag=1;
 437   3           shutdown_c=1;
 438   3           time_s_kj=0;
 439   3           start_flag1=1; 
 440   3           start_flag=0;
 441   3         }
 442   2      
 443   2      if(time_s_kj>=60&&start_flag==0)
 444   2        { shutdown_s=1;
 445   3          start_flag=1;
 446   3          KJOK=0;
 447   3         }
 448   2      if(start==1)
 449   2        {start_flag1=0;
 450   3         }
 451   2      
 452   2      
 453   2      if(KJOK==0&&GJOK==1)
 454   2      {
 455   3      //自动烟雾
 456   3      if(time_s>=1200)
 457   3        { shutdown_f=1;
 458   4       
 459   4           if(time_s>=1800)
 460   4             { 
 461   5                      smog_open=1;
 462   5                       if(time_s>=1815)
 463   5                 {  smog_open=0;
 464   6                    shutdown_f=0;
 465   6                    time_s=0;
 466   6                 }
 467   5             }
 468   4        }
 469   3       //烟雾手动
 470   3      if(smog_hand==0&&sh_flag==0)    
 471   3       {delay();
 472   4       if(smog_hand==0&&sh_flag==0)
 473   4       { shutdown_f=1;
 474   5         time_s_3=0;
 475   5         sh_flag=1;
 476   5         auto_flag=0;
 477   5       }
 478   4       }
 479   3      if(time_s_3>=600&&auto_flag==0)
 480   3       {      smog_open=1;   //放烟雾
 481   4          if(time_s_3>=615)
 482   4            { smog_open=0;//停止放烟
 483   5              shutdown_f=0;//关烟雾器
 484   5              auto_flag=1;
 485   5                      sh_flag=0;
 486   5            }
 487   4       }
 488   3      
 489   3      //连续播放
C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 9   

 490   3      if(play_1==0&&play1_flag==0&&CO==1)
 491   3         {  delay();
 492   4            if(play_1==0&&play1_flag==0&&CO==1)
 493   4              { play1_flag=1;
 494   5                send_buf[0] =0x71;   
 495   5                send_buf[1] ='P';
 496   5                send_buf[2] ='L';
 497   5                send_buf[3] =',';
 498   5                send_buf[4]=0x0a;
 499   5                send_buf[5] =0x23;
 500   5                send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5])%0x100
             -);
 501   5                send_buf[6] =send_check;
 502   5                send_buf[7] =0x0d;
 503   5                send_status =0;
 504   5                SBUF=send_buf[0]; 
 505   5              }
 506   4              }
 507   3      if(play_1==1||CO==0)
 508   3         {play1_flag=0;}
 509   3      
 510   3      //单次播放
 511   3      if(play_2==0&&play2_flag==0&&CO==1)
 512   3        {delay();
 513   4         if(play_2==0&&play2_flag==0&&CO==1)
 514   4           {CCAPM1=0x11;
 515   5            CCAPM2=0x11;
 516   5            CCAPM3=0x11;
 517   5            CCAPM4=0x11;
 518   5                EC=1;
 519   5                play2_flag=1;
 520   5               }
 521   4      } 
 522   3      if(play_2==1||CO==0)
 523   3      {play2_flag=0;
 524   4      CCAPM1=0x00;
 525   4      CCAPM2=0x00;
 526   4      CCAPM3=0x00;
 527   4      CCAPM4=0x00;
 528   4      EC=0;}
 529   3      
 530   3      if(pp==0&&qmend==0&&play2_flag==1)
 531   3              { CCAPM1=0x00;
 532   4                CCAPM2=0x00;
 533   4                CCAPM3=0x00;
 534   4                CCAPM4=0x00;
 535   4                        EC=0;
 536   4                        pp=1;
 537   4                       
 538   4                qmend=1;
 539   4                send_buf[0]=0x71;   
 540   4                send_buf[1]='P';
 541   4                send_buf[2]='L';
 542   4                send_buf[3]=',';
 543   4                send_buf[4]=qunum;    //播放曲目
 544   4                send_buf[5]=0x23;
 545   4                send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5])%0x100
             -);
 546   4                send_buf[6]=send_check;
 547   4                send_buf[7]=0x0d;
 548   4                send_status=0;
 549   4                SBUF=send_buf[0];
C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 10  

 550   4               }
 551   3              
 552   3           
 553   3      
 554   3       
 555   3      
 556   3      //暂停播放
 557   3      if(CO==0&&play_1==0&&pause==0)
 558   3         {delay();
 559   4          if(CO==0&&play_1==0&&pause==0)
 560   4            {pause=1;
 561   5             send_buf[0] =0x71;   
 562   5             send_buf[1] ='S';
 563   5             send_buf[2] ='T';
 564   5             send_buf[3] =',';
 565   5             send_buf[4]=0;
 566   5             send_buf[5] =0x23;
 567   5             send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5]) %0x100);
 568   5             send_buf[6] =send_check;
 569   5             send_buf[7] =0x0d;
 570   5             send_status =0;
 571   5             SBUF=send_buf[0];
 572   5            }
 573   4         }
 574   3      if(CO!=0||play_1!=0)
 575   3      {pause=0;}
 576   3      
 577   3      //继续播放
 578   3      if(CO==0&&play_2==0&&con==0)
 579   3         {delay();
 580   4          if(CO==0&&play_2==0&&con==0)
 581   4            { con=1;
 582   5              send_buf[0] =0x71;
 583   5              send_buf[1] ='P';
 584   5              send_buf[2] ='L';
 585   5              send_buf[3] =',';
 586   5              send_buf[4]=0;
 587   5              send_buf[5] =0x23;
 588   5              send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5])%0x100);
 589   5              send_buf[6] =send_check;
 590   5              send_buf[7] =0x0d;
 591   5              send_status =0;
 592   5              SBUF=send_buf[0];
 593   5            }  
 594   4          }
 595   3      if(CO!=0||play_2!=0)
 596   3           {con=0;}
 597   3      
 598   3      
 599   3      if(receive_status==1)
 600   3      {
 601   4       receive_check=0xa5^( receive_buf[0]+receive_buf[1]+receive_buf[2]+receive_buf[3]+receive_buf[4]+receive_b
             -uf[5] ) %0x100 ;
 602   4      if (receive_buf[0]==0x73&&receive_buf[1]==0x44&&receive_buf[2]==0x55&&receive_buf[3]==0x2c&&receive_buf[4]
             -==0&&receive_buf[5]==0x23&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 603   4      // if() 
 604   4        {     qmend=0;
 605   5           CCAPM1=0x11;
 606   5           CCAPM2=0x11;
 607   5           CCAPM3=0x11;
 608   5           CCAPM4=0x11;
 609   5           EC=1; 
C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 11  

 610   5           send_buf[0] =0x71;  
 611   5           send_buf[1] ='D';
 612   5           send_buf[2] ='U';
 613   5           send_buf[3] ='O';
 614   5           send_buf[4]='K';
 615   5           send_buf[5] =0x23;
 616   5           send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5]) %0x100);
 617   5           send_buf[6] =send_check;
 618   5           send_buf[7] =0x0d;
 619   5               send_status =0;
 620   5               SBUF=send_buf[0];
 621   5                       
 622   5        }
 623   4       if(receive_buf[0]==0x73&&(receive_buf[1]!=0x44||receive_buf[2]!=0x55||receive_buf[3]!=0x2c||receive_buf[4
             -]!=0||receive_buf[5]!=0x23||receive_buf[6]!=receive_check||receive_buf[7]!=0x0d))
 624   4        {     qmend=1;
 625   5      
 626   5          send_buf[0] =0x71;   
 627   5          send_buf[1] ='D';
 628   5          send_buf[2] ='U';
 629   5          send_buf[3] ='E';
 630   5          send_buf[4]='R';
 631   5          send_buf[5] =0x23;
 632   5          send_check=0xa5^((send_buf[0]+send_buf[1]+send_buf[2]+send_buf[3]+send_buf[4]+send_buf[5])%0x100);
 633   5          send_buf[6] =send_check;
 634   5          send_buf[7] =0x0d;
 635   5              send_status =0;
 636   5          SBUF=send_buf[0];
 637   5          }
 638   4      if (receive_buf[0]==0x7a&&receive_buf[1]=='C'&&receive_buf[2]=='O'&&receive_buf[3]=='O'&&receive_buf[4]=='
             -K'&&receive_buf[5]=='#'&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 639   4              { time_s_gj=0;  
 640   5                CO_flag=0; 
 641   5            GJOK=0;
 642   5            EC=0;
 643   5            start_flag=1;
 644   5            enable=0;}        
 645   4      /*
 646   4       //              //关机信息发送不成功,再发送一遍
 647   4       if (receive_buf[0]==0x7a&&receive_buf[1]=='S'&&receive_buf[2]=='T'&&receive_buf[3]=='O'&&receive_buf[4]==
             -'K'&&receive_buf[5]=='#'&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 648   4          {play1_flag=1;receive_status=0; }       
 649   4       //if (receive_buf[0]==0x7a&&receive_buf[1]=='S'&&receive_buf[2]=='T'&&receive_buf[3]=='E'&&receive_buf[4]
             -=='R'&&receive_buf[5]=='#'&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 650   4          //  {play1_flag=0; }        //暂停信息发送不成功,再发送一次
 651   4       if(receive_buf[0]==0x7a&&receive_buf[1]=='P'&&receive_buf[2]=='L'&&receive_buf[3]=='O'&&receive_buf[4]=='
             -K'&&receive_buf[5]=='#'&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 652   4        {receive_status=0;}   //      单次信息发送成功,       `
 653   4       if (receive_buf[0]==0x7a&&receive_buf[1]=='P'&&receive_buf[2]=='L'&&receive_buf[3]=='E'&&receive_buf[4]==
             -'R'&&receive_buf[5]=='#'&&receive_buf[6]==receive_check&&receive_buf[7]==0x0d)
 654   4           {play2_flag=0;pp=0;qmend=0;con=0;pause=0;} //单次、继续、连续信息发送不成功,再发送一次   */
 655   4      
 656   4      receive_status=0;  
 657   4      }                
 658   3      
 659   3      }
 660   2      
 661   2      }
 662   1      
 663   1      }


C51 COMPILER V8.05a   TEXT1                                                                09/23/2007 11:15:54 PAGE 12  

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


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

⌨️ 快捷键说明

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