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

📄 main.lst

📁 proteus 的51实验板 .
💻 LST
📖 第 1 页 / 共 3 页
字号:
 504   1            _nop_();
 505   1      _nop_();
 506   1             SDA=1;            //8 位发送完后释放数据线准备收应答位
 507   1             _nop_();
 508   1      _nop_();
 509   1      SCL=1;           //开始接收应答信号
 510   1      _nop_();
 511   1      _nop_();
 512   1      _nop_();
 513   1      _nop_();
 514   1             _nop_();     //判断是否接收到应答信号正常转AckEnd
 515   1      _nop_();
 516   1      SCL=0;       //发送结束钳住总线准备下一步发送或接收数据或进行其它处理            
 517   1        
 518   1      return read;   */ 
 519   1      }
 520          //*********************************************************************************
 521          //   地址为addr PCF8574      作为准双向口输出 
 522          //************************************************************************************
 523          void output_control(unsigned char  addr, unsigned char  outdata)
 524          {
 525   1      slvadr=addr;
 526   1      senddata(outdata);
 527   1      }
 528          unsigned char  read(unsigned char  addr)
 529          {
 530   1            unsigned char  datauci=0;
 531   1            IIC_Start();
 532   1            sentbyte(addr);
 533   1            IIC_Stop();
 534   1                datauci=getbyte();     
 535   1            //sentbyte(datauci);
 536   1            
 537   1                 //   while(1);
 538   1      return    datauci;
 539   1      
 540   1      }
 541          
 542          
 543          
 544          
 545          
 546          
 547           void delay2(unsigned char i) 
 548          {
 549   1      while(--i); 
 550   1      } 
 551          main()
C51 COMPILER V8.08   MAIN                                                                  02/14/2008 16:13:50 PAGE 10  

 552          {unsigned char  num=0, time[3],dat[2],sec[3];   
 553   1      unsigned int  johu;
 554   1      // init_serialcomm();
 555   1           SCON  = 0x40;       //SCON: serail mode 1, 8-bit UART, enable ucvr   
 556   1               TMOD |= 0x20;       //TMOD: timer 1, mode 2, 8-bit reload  
 557   1               PCON |= 0x80;       //SMOD=1;  
 558   1                TH1   = 0xFD;
 559   1                TL1   = 0xFD;       //Baud:19200   fosc=11.0592MHz   
 560   1               // IE   |= 0x90;       //Enable Serial Interrupt    
 561   1                      TR1   = 1;          // timer 1 run  
 562   1                       // TI=1;                 
 563   1      ce_62256=1;oe_62256=1;wr_62256=1; 
 564   1      
 565   1      dat[0]= 0x31;
 566   1      dat[1]= 0x0c;
 567   1      PCF8583_WriteDat(0x05,2,dat);
 568   1      time[0]=0x55;
 569   1      time[1]=0x59;
 570   1      time[2]=0x23;
 571   1      PCF8583_WriteDat(0x02,3,time);
 572   1      TLC1456_clr=1;
 573   1       while(1)
 574   1       {
 575   2               if (!(P2 & 0x10 )      )
 576   2                {      delay2(200);//delay2(200);delay2(200);delay2(200);delay2(200);delay2(200);
 577   3                  
 578   3                      if (!(P2 & 0x10 )       )
 579   3                      {  SendD(johu++,1)       ;
 580   4                         SendD(johu++,0)       ;
 581   4                         if (johu==255)
 582   4                          johu=0;
 583   4              }
 584   3                }
 585   2               if (!(P2 & 0x08 )      )
 586   2                {      delay2(200);//delay2(200);delay2(200);delay2(200);delay2(200);delay2(200);
 587   3                  
 588   3                      if (!(P2 & 0x08 )       )
 589   3                      { 
 590   4                              johu=get_ADC();
 591   4                              send_char_com((johu/1000)%10 + '0');
 592   4                              send_char_com((johu/100)%10 + '0');
 593   4                              send_char_com((johu/10)%10 + '0');
 594   4                              send_char_com((johu)%10 + '0'); 
 595   4                              send_char_com(0x0d);send_char_com(0x0a);
 596   4              }
 597   3                }
 598   2       }
 599   1      
 600   1       while(1)        
 601   1       {                              
 602   2      
 603   2                if (!(P2 & 0x08 )     )
 604   2                {      delay2(200);
 605   3                      if (!(P2 & 0x08 )       )
 606   3                      {
 607   4                      
 608   4                               PCF8583_ReadDat(0x00,3,sec);
 609   4                           PCF8583_ReadDat(0x02,3,time);
 610   4                               PCF8583_ReadDat(0x05,2,dat);
 611   4                               
 612   4                      send_char_com(0x0d);send_char_com(0x0a);
 613   4                      johu=read(0x41);
C51 COMPILER V8.08   MAIN                                                                  02/14/2008 16:13:50 PAGE 11  

 614   4                      output_control(0x42,johu);
 615   4                      //output_control(0x40,0xf0);
 616   4      
 617   4      
 618   4                      send_char_com((johu/100)%10 + '0');
 619   4                      send_char_com((johu/10)%10 + '0');
 620   4                      send_char_com((johu)%10 + '0');
 621   4                      send_char_com(0x0d);send_char_com(0x0a);
 622   4                                                                                                       
 623   4                               send_char_com((dat[1] >> 4)/10 + '0');
 624   4                               send_char_com((dat[1] >> 4)%10 + '0');                  
 625   4                               send_char_com(' ');
 626   4                               send_char_com((dat[1] & 0x0f)/10 + '0');
 627   4                               send_char_com((dat[1] & 0x0f)%10 + '0');                        
 628   4                               send_char_com(' ');                                                     
 629   4                               send_char_com((dat[0] >> 4) + '0');               
 630   4                               send_char_com((dat[0] & 0x0f) + '0');
 631   4                               //send_char_com((dat[0] & 0x0f)/10 + '0');
 632   4                               //send_char_com((dat[0] & 0x0f)%10 + '0'); 
 633   4                  send_char_com(0x0d);send_char_com(0x0a);
 634   4      
 635   4      
 636   4                               send_char_com(((time[2] >> 4) & 0x03) + '0');
 637   4                               send_char_com((time[2] & 0x0f) + '0');
 638   4                               
 639   4                               send_char_com(':');
 640   4                               send_char_com((time[1] >> 4) + '0');
 641   4                               send_char_com((time[1] & 0x0f) + '0');
 642   4                               
 643   4                               send_char_com(':');                                                                                     
 644   4                               send_char_com((time[0] >> 4) + '0');
 645   4                               send_char_com((time[0] & 0x0f) + '0');
 646   4      
 647   4                      send_char_com(' ');send_char_com(' ');send_char_com(' ');send_char_com(' ');     
 648   4                               send_char_com(((sec[2] >> 4) & 0x03) + '0');
 649   4                               send_char_com((sec[2] & 0x0f) + '0');
 650   4                               
 651   4                               send_char_com(':');
 652   4                               send_char_com((sec[1] >> 4) + '0');
 653   4                               send_char_com((sec[1] & 0x0f) + '0');
 654   4                               
 655   4                               send_char_com(':');                                                                                     
 656   4                               send_char_com((sec[0] >> 4) + '0');
 657   4                               send_char_com((sec[0] & 0x0f) + '0');
 658   4                               
 659   4                              /* send_char_com(time[0]);
 660   4                               send_char_com(time[1]);
 661   4                               send_char_com(time[2]);
 662   4                              send_char_com();send_char_com();send_char_com();   */            
 663   4      
 664   4      
 665   4                              send_char_com(0x0d);send_char_com(0x0a);send_char_com(0x0d);send_char_com(0x0a);
 666   4                              
 667   4                      }
 668   3                }
 669   2       }
 670   1        
 671   1       while(1) 
 672   1       { 
 673   2         for (num=0;num<=254;num++)
 674   2         { ce_62256=0;oe_62256=1;wr_62256=0 ;
 675   3               P0=num;
C51 COMPILER V8.08   MAIN                                                                  02/14/2008 16:13:50 PAGE 12  

 676   3               //ce_62256=1;
 677   3               //wr_62256=1;
 678   3              
 679   3               P1=255-num     ;
 680   3              ce_62256=1;oe_62256=1;wr_62256=1 ;
 681   3               
 682   3         }
 683   2         if (!(P2 & 0x08 )    )
 684   2                {      wr_62256=1;
 685   3                  
 686   3                 for (num=0;num<255;num++)
 687   3                        {                                                             
 688   4                              ce_62256=0;oe_62256=0;wr_62256=1 ;
 689   4                              P0=num;
 690   4                              
 691   4                              P1=0xff;
 692   4                              send_char_com(P1);
 693   4                              ce_62256=1;oe_62256=0;wr_62256=1 ;
 694   4      
 695   4                        }
 696   3                }
 697   2       }
 698   1      }
 699          
 700          
 701          
 702          
 703          /*void delay2(unsigned char i) 
 704          {
 705          while(--i); 
 706          } 
 707          为最佳方法。
 708          
 709          
 710          分析:假设外挂12M(之后都是在这基础上讨论)
 711          我编译了下,传了些参数,并看了汇编代码,观察记录了下面的数据:
 712          delay2(0):延时518us 518-2*256=6
 713          delay2(1):延时7us(原帖写“5us”是错的,^_^)
 714          delay2(10):延时25us 25-20=5
 715          delay2(20):延时45us 45-40=5
 716          delay2(100):延时205us 205-200=5
 717          delay2(200):延时405us 405-400=5
 718          
 719          见上可得可调度为2us,而最大误差为6us。
 720          精度是很高了!
 721          
 722          但这个程序的最大延时是为518us,显然不能满足实际需要,因为很多时候需要延迟比较长的时间。
 723          
 724          
 725          那么,接下来讨论将t分配为两个字节,即uint型的时候,会出现什么情况。
 726          
 727          void delay8(uint t)
 728          {
 729          while(--t);
 730          }
 731          我编译了下,传了些参数,并看了汇编代码,观察记录了下面的数据:
 732          delay8(0):延时524551us 524551-8*65536=263
 733          delay8(1):延时15us
 734          delay8(10):延时85us 85-80=5 
 735          delay8(100):延时806us 806-800=6
 736          delay8(1000):延时8009us 8009-8000=9
 737          delay8(10000):延时80045us 80045-8000=45
C51 COMPILER V8.08   MAIN                                                                  02/14/2008 16:13:50 PAGE 13  

 738          delay8(65535):延时524542us 524542-524280=262
 739          
 740          如果把这个程序的可调度看为8us,那么最大误差为263us,但这个延时程序还是不能满足要求的,因为延时最大为524.55
             -1ms。
 741          
 742          */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    810    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1      29
   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 + -