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

📄 ledtest.lst

📁 The information in this publication is believed to be accurate as of its publication date. Such info
💻 LST
📖 第 1 页 / 共 4 页
字号:
 460   1                                   // read and calculate the read crc
 461   1                                 docrc16(temp1);
 462   1                                 lastcrc16 = docrc16(temp2);
 463   1                                 // crc should now be 0xB001
 464   1                                 if (lastcrc16 != 0xB001)
 465   1                                     {
 466   1                                                                  ow_reset();
 467   1                                                      tx_str("make PIOA high crc error!");
 468   1                                                         }
 469   1                               else{
 470   1                                        tx_str("make PIOA high crc correct!");
 471   1                                               }
 472   1                                  tx_lfbs(); 
 473   1                                                               
 474   1                                   /*  ow_reset();                
 475   1                                                     write_byte(0xCC);   //LSB address
 476   1                                     write_byte(0x55);   //MSB address
 477   1                                                     write_byte(0x07);   //LSB address
 478   1                                     write_byte(0x00);   //MSB address
 479   1                                 write_byte(0x6d);  //
 480   1                                 temp1=read_byte();
 481   1                                                         temp2=read_byte();
 482   1                                                        // crcbit=read_bit();
 483   1                                                         setcrc16(0x0000);     //
 484   1                                 docrc16(0x55);
 485   1                                 docrc16(0x07);
 486   1                                 docrc16(0x00);
 487   1                                                         docrc16(0x6d);
 488   1                                   // read and calculate the read crc
 489   1                                 docrc16(temp1);
C51 COMPILER V7.06   LEDTEST                                                               11/22/2005 22:07:04 PAGE 9   

 490   1                                 lastcrc16 = docrc16(temp2);
 491   1                                 // crc should now be 0xB001
 492   1                                 if (lastcrc16 != 0xB001)
 493   1                                     {
 494   1                                                                  ow_reset();
 495   1                                                      tx_str("make PIOA low crc error!");
 496   1                                                         }
 497   1                               else{
 498   1                                        tx_str("make PIOA low crc correct!");
 499   1                                               }
 500   1                                  tx_lfbs(); 
 501   1                                                               delay(10000);
 502   1                                                               ow_reset();                
 503   1                                                     write_byte(0xCC);   //LSB address
 504   1                                     write_byte(0xaa);   //MSB address
 505   1                                                     write_byte(0x07);   //LSB address
 506   1                                     write_byte(0x00);   //MSB address
 507   1                                 test=read_byte();  //LSB address
 508   1                                 temp1=read_byte();
 509   1                                                         temp2=read_byte();
 510   1                                                        // crcbit=read_bit();
 511   1                                                         setcrc16(0x0000);     //
 512   1                                 docrc16(0xaa);
 513   1                                 docrc16(0x07);
 514   1                                 docrc16(0x00);
 515   1                                                         docrc16(test);
 516   1                                   // read and calculate the read crc
 517   1                                 docrc16(temp1);
 518   1                                 lastcrc16 = docrc16(temp2);
 519   1                                 // crc should now be 0xB001
 520   1                                 if (lastcrc16 != 0xB001)
 521   1                                     {
 522   1                                                                  ow_reset();
 523   1                                                      tx_str("read status crc error!");
 524   1                                                         }
 525   1                               else{
 526   1                                        tx_str("read status crc correct!");
 527   1                                               }
 528   1                                  tx_lfbs(); 
 529   1                                           if (test==0xff)
 530   1                                                                     {
 531   1                                                                           tx_str("read_byte=0xff!");
 532   1                                                                               tx_lfbs();
 533   1                                                                              }
 534   1                                                                 else if(test<=48) {  
 535   1                                                               tx_str("read_byte=");
 536   1                                                                               tx_char((test+48));
 537   1                                                                                tx_lfbs();
 538   1                                                                              }
 539   1                                                                              else {  tx_str("read_byte=");
 540   1                                                                               tx_char((test));
 541   1                                                                                tx_lfbs();
 542   1                                                                              }*/
 543   1                                                      /* break;
 544   1                         case '8':
 545   1                                 ow_reset();                
 546   1                                                     write_byte(0xCC);   //skip command
 547   1                                     write_byte(0x55);   //write status command
 548   1                                                     write_byte(0x07);   //LSB address
 549   1                                     write_byte(0x00);   //MSB address
 550   1                                 write_byte(0x6d);  //data
 551   1                                 temp1=read_byte();
C51 COMPILER V7.06   LEDTEST                                                               11/22/2005 22:07:04 PAGE 10  

 552   1                                                         temp2=read_byte();
 553   1                                                        // crcbit=read_bit();
 554   1                                                         setcrc16(0x0000);     //
 555   1                                 docrc16(0x55);
 556   1                                 docrc16(0x07);
 557   1                                 docrc16(0x00);
 558   1                                                         docrc16(0x6d);
 559   1                                   // read and calculate the read crc
 560   1                                 docrc16(temp1);
 561   1                                 lastcrc16 = docrc16(temp2);
 562   1                                 // crc should now be 0xB001
 563   1                                 if (lastcrc16 != 0xB001)
 564   1                                     {
 565   1                                                                  ow_reset();
 566   1                                                      tx_str("make PIOA low(Channel FF = 1 transistor off) crc error!");
 567   1                                                         }
 568   1                               else{
 569   1                                        tx_str("make PIOA low(Channel FF = 1 transistor off) crc correct!");
 570   1                                               }
 571   1                                  tx_lfbs(); 
 572   1                                                      //       delay(10000);
 573   1                                                       break;
 574   1                default:   
 575   1                                  tx_str("default break!");
 576   1                                              break;
 577   1                       }
 578   1                       }*/
 579   1         while(1);
 580   1        }
 581          
 582           /*unsigned char rx_char(void)
 583              {
 584                     while(!RI)
 585                        {;}
 586                     RI=0;
 587                     return SBUF;
 588                   }*/
 589          
 590          void tx_str(unsigned char *str)
 591              {int i;
 592   1            for (i=0;i<strlen(str);i++)
 593   1                      {
 594   2                                tx_char(str[i]);
 595   2                      }
 596   1              }
 597          void tx_char(unsigned char c)
 598             {
 599   1          while(!TI)
 600   1                {
 601   2                 ;
 602   2                 }
 603   1                 TI=0;
 604   1                 SBUF=c;
 605   1               }
 606          
 607          void tx_lfbs(void)
 608              {int y;
 609   1                       tx_char(0x0A);
 610   1                      for (y=0;y<70;y++)
 611   1                               {
 612   2                    tx_char(0x08);
 613   2                              }
C51 COMPILER V7.06   LEDTEST                                                               11/22/2005 22:07:04 PAGE 11  

 614   1               }
 615          void Led_blink(void)
 616            {
 617   1        int i;
 618   1            for(i=0;i<10;i++)
 619   1                {
 620   2                 P15=1;
 621   2                     delay(200);
 622   2                     P15=0;
 623   2                     delay(200);
 624   2                    }
 625   1              }
 626          
 627          void Init_Rs232(void)
 628             {IE=0X00;
 629   1          SCON=0x50;
 630   1          TMOD=0x20;
 631   1              TH1=0xfd;
 632   1              TL1=0xfd;
 633   1              TR1=1;
 634   1              TI=1;
 635   1         }
 636          
 637           void delay(int delay)
 638            {int i,j;
 639   1         for (i=0;i<delay;i++)
 640   1            for (j=0;j<255;j++);
 641   1         }
 642          
 643          
 644          // WRITE_BIT - writes a bit to the one-wire bus, passed in bitval.
 645          //
 646          void write_bit(char bitval)
 647          {
 648   1        if (bitval==0)
 649   1            {
 650   2                 writedatalow();
 651   2                 }
 652   1        else{
 653   2             writedatahigh();
 654   2                 }
 655   1      }// Delay provides 16us per loop, plus 24us. Therefore delay(5) = 104us
 656          // WRITE_BYTE - writes a byte to the one-wire bus.
 657          //
 658          /*void writedatalow(void)
 659            {
 660            }
 661          
 662          void writedatahigh(void)
 663            {int count=6000;
 664          
 665             owData=0;
 666             owRst=0;
 667             wdelay(1);
 668             owData=1;
 669             owRst=1;
 670             owEn=1;
 671             owBsy=1;
 672             wdelay(1);
 673             owEn=0;
 674             while(count!=0)
 675                 {
C51 COMPILER V7.06   LEDTEST                                                               11/22/2005 22:07:04 PAGE 12  

 676                       if(
 677             }*/
 678          
 679          void write_byte(char val)
 680          {
 681   1      unsigned char i;
 682   1      unsigned char temp;
 683   1      for (i=0; i<8; i++) // writes byte, one bit at a time
 684   1      {
 685   2      temp = val>>i; // shifts val right 'i' spaces
 686   2      temp &= 0x01; // copy that bit to temp
 687   2      write_bit(temp); // write bit in temp into
 688   2      }
 689   1      wdelay(5);
 690   1      }
 691          
 692          unsigned char read_bit(void)

⌨️ 快捷键说明

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