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

📄 csy.lst

📁 本程序能实现温度的实时采集与显示
💻 LST
📖 第 1 页 / 共 5 页
字号:
 524   1                                      tmreset();
 525   1                                      tmwbyte(0x0CC);
 526   1                                      tmwbyte(0x044);
 527   1                      
 528   1                                      tmreset();
 529   1                                      tmwbyte(0x0CC);
 530   1                                      tmwbyte(0x0BE);
 531   1                              
 532   1                                      a=tmrbyte(); //低8位
 533   1                                      b=tmrbyte(); //高8位
 534   1      
 535   1                                      a2=a&0x0F;
 536   1                                      w1=hextobcd1(a2); //小数(整型)
 537   1      
 538   1                                      a2=a&0x0F0;
 539   1                                      a2=a2>>4;
 540   1                                      b2=b&0x00F;
 541   1                                      b2=b2<<4;
 542   1                                      a2=a2|b2;
 543   1      
 544   1                                      da1=a2/10; //整数部分十位
 545   1                                      da2=a2%10; //整数部分个位
 546   1      
 547   1                                      cha[0]=' ';
 548   1                                      b2=b&0x0F0;
 549   1                                      if(b2)
 550   1                                              cha[1]='-';     
 551   1                                      else
C51 COMPILER V7.06   CSY                                                                   11/16/2007 16:56:48 PAGE 10  

 552   1                                              cha[1]='+';
 553   1                                      cha[2]=inttochar(da1);
 554   1                                      cha[3]=inttochar(da2);
 555   1                                      cha[4]='.';
 556   1                                      cha[5]=inttochar(w1);
 557   1                                      cha[6]='\0';                            
 558   1      printf("%s\n",cha);                     
 559   1      //fa2=atof(cha);
 560   1      
 561   1                                      for(j=1;j<=5;j++)
 562   1                                              {
 563   2                                              for(i=1;i<=200;i++)
 564   2                                                      Delay_Count(255);
 565   2                                              }
 566   1      
 567   1      
 568   1      //  s=1;
 569   1      //   WRCommand(0x01);   //清除显示DDRAM
 570   1         ShowQQChar(0x9B,cha,3);
 571   1      ShowQQChar(0x9E,chinese11,lengthCF11);
 572   1      //   if (enter==0)
 573   1      //              break;
 574   1              }
 575          //}
 576          //温度显示结束
 577          
 578          //pH值子程序开始
 579          void phv()
 580          {
 581   1       float volts,lr,ave;
 582   1       int i,k,decimation,samples;
 583   1       decimation=1728;
 584   1       CKCON=0;
 585   1      // printf("MSC1210 ADC teperature test :\n");
 586   1       USEC=10;
 587   1       ACLK=9;
 588   1       ADMUX=0x08;
 589   1       PDCON&=0xF7;
 590   1       //ODAC=0x00;
 591   1       ADCON0=0x30;//pga=1
 592   1       ADCON2=decimation&0xff;
 593   1       ADCON3=(decimation>>8)&0x07;
 594   1       ADCON1=0x01;
 595   1       printf("Calibrating......\n");
 596   1       for (k=0;k<4;k++)
 597   1       {
 598   2        while (!(AIE&0x20));
 599   2        lr=bipolar();
 600   2       }
 601   1       //ODAC=0x7f;
 602   1       samples=10;
 603   1      // while(1)
 604   1      // {
 605   1        ave=0;
 606   1        for (i=0;i<samples;i++)
 607   1        {
 608   2         while(!(AIE&0x20));
 609   2         ave+=bipolar()*LSB;
 610   2        }
 611   1        volts=ave/samples;
 612   1      
 613   1        printf("volts=%f\r\n",volts);
C51 COMPILER V7.06   CSY                                                                   11/16/2007 16:56:48 PAGE 11  

 614   1      // }
 615   1      }
 616          //pH值子程序结束
 617          
 618          
 619          void firstscreen(void)
 620          
 621          {
 622   1      //一屏
 623   1        s=1;
 624   1         WRCommand(0x01);     //清除显示DDRAM
 625   1         ShowQQChar(0x80,chinese1,lengthCF1);
 626   1         ShowQQChar(0x90,chinese2,lengthCF2);
 627   1         ShowQQChar(0x88,chinese3,lengthCF3);
 628   1         ShowQQChar(0x98,chinese4,lengthCF4);
 629   1         temp();
 630   1         WaitNms(250);                //等待时间
 631   1         WaitNms(250);
 632   1       //等待时间
 633   1      
 634   1      }
 635          
 636          void pHsecondscreen(void)
 637          {
 638   1      //二屏
 639   1         s=2;
 640   1         LCDInit();
 641   1         RDBF();
 642   1         WRCommand(0x01);     //清除显示DDRAM
 643   1         ShowQQChar(0x80,chinese5,lengthCF5);
 644   1         ShowQQChar(0x87,chinese1,lengthCF1);
 645   1         ShowQQChar(0x90,chinese6,lengthCF6);
 646   1         ShowQQChar(0x88,chinese7,lengthCF7);
 647   1         ShowQQChar(0x98,chinese8,lengthCF8);
 648   1         WaitNms(250);                //等待时间
 649   1         WaitNms(250);                //等待时间
 650   1      
 651   1      }
 652          
 653          void DOsecondscreen(void)
 654          {
 655   1      //二屏
 656   1         s=3;
 657   1         LCDInit();
 658   1         RDBF();
 659   1         WRCommand(0x01);     //清除显示DDRAM
 660   1         //ShowQQChar(0x80,chinese5,lengthCF5);
 661   1         ShowQQChar(0x87,chinese2,lengthCF2);
 662   1         ShowQQChar(0x90,chinese5,lengthCF5);
 663   1         ShowQQChar(0x88,chinese9,lengthCF9);
 664   1         ShowQQChar(0x98,chinese8,lengthCF8);
 665   1         WaitNms(250);                //等待时间
 666   1         WaitNms(250);                //等待时间
 667   1      
 668   1      }
 669          
 670          void Fsecondscreen(void)
 671          {
 672   1      //二屏
 673   1         s=4;
 674   1         LCDInit();
 675   1         RDBF();
C51 COMPILER V7.06   CSY                                                                   11/16/2007 16:56:48 PAGE 12  

 676   1         WRCommand(0x01);     //清除显示DDRAM
 677   1         //ShowQQChar(0x80,chinese5,lengthCF5);
 678   1         ShowQQChar(0x87,chinese3,lengthCF3);
 679   1         ShowQQChar(0x90,chinese5,lengthCF5);
 680   1         ShowQQChar(0x88,chinese9,lengthCF9);
 681   1         ShowQQChar(0x98,chinese8,lengthCF8);
 682   1         WaitNms(250);                //等待时间
 683   1         WaitNms(250);                //等待时间
 684   1      
 685   1      }
 686          
 687          void Tsecondscreen(void)
 688          {
 689   1      //二屏
 690   1         s=5;
 691   1         LCDInit();
 692   1         RDBF();
 693   1         WRCommand(0x01);     //清除显示DDRAM
 694   1         //ShowQQChar(0x80,chinese5,lengthCF5);
 695   1         ShowQQChar(0x87,chinese4,lengthCF4);
 696   1         ShowQQChar(0x88,chinese10,lengthCF10);
 697   1         temp();  
 698   1         //ShowQQChar(0x88,chinese9,lengthCF9);
 699   1         ShowQQChar(0x98,chinese8,lengthCF8);
 700   1         WaitNms(250);                //等待时间
 701   1         WaitNms(250);                //等待时间
 702   1      
 703   1      }
 704          
 705          
 706          //主函数
 707          void main(void)
 708          {
 709   1      
 710   1      //读写flash变量
 711   1      FTCON=0x64;
 712   1      USEC=11-1;
 713   1      MSEC=11059-1;
 714   1      //上为读写flash变量
 715   1      //ph=12.45;
 716   1      //sprintf(sph,"%5.2f",ph);
 717   1       autobaud();
 718   1      //printf("OK");
 719   1         //printf("%s",sph);
 720   1        LCDInit();
 721   1      RDBF();
 722   1       // printf("已调用完判忙函数\r\n");
 723   1      
 724   1      
 725   1      WRCommand(0x01);        //清除显示DDRAM
 726   1        // ShowQQChar(0x80,sph,3);
 727   1       printf("已调用完判忙函数\r\n");
 728   1       
 729   1       b=4;
 730   1      firstscreen();
 731   1      while(1)
 732   1              {
 733   2                      if(s==1)
 734   2                      {
 735   3                              temp();
 736   3                              phv();
 737   3                      
C51 COMPILER V7.06   CSY                                                                   11/16/2007 16:56:48 PAGE 13  

 738   3                      }
 739   2      
 740   2      //              dat=flash_read(0,0);
 741   2      //              printf("dat=%d\n",dat);
 742   2      //              flash_write(0,0,0x0B);
 743   2      //              dat=flash_read(0,0);
 744   2      //              printf("dat=%d\n",dat);
 745   2      //              while(RI=0);
 746   2      //              RI=0;
 747   2      
 748   2      //b为行标志,s为屏标志
 749   2              if(up==0 && b==4)  
 750   2                  { WaitNms(250);
 751   3              WaitNms(250);
 752   3              WaitNms(250);
 753   3              
 754   3                      WRCommand(0x88);
 755   3                     b=3;
 756   3                   }
 757   2              if(down==0&& b==4)
 758   2                     {WaitNms(250);
 759   3              WaitNms(250);
 760   3              WaitNms(250);
 761   3              
 762   3                         WRCommand(0x80);
 763   3                      b=1;
 764   3                   }
 765   2                 
 766   2              if(up==0 && b==3)
 767   2                 {WaitNms(250);
 768   3              WaitNms(250);
 769   3              WaitNms(250);
 770   3              
 771   3                 WRCommand(0x90);
 772   3                     b=2;
 773   3                    }
 774   2              if(down==0 && b==3)
 775   2                     {WaitNms(250);
 776   3              WaitNms(250);
 777   3              WaitNms(250);
 778   3              
 779   3                         WRCommand(0x98);
 780   3                      b=4;
 781   3                  }
 782   2              if(up==0 && b==2)
 783   2                 {WaitNms(250);
 784   3              WaitNms(250);
 785   3              WaitNms(250);
 786   3              
 787   3                  WRCommand(0x80);
 788   3              
 789   3                     b=1;

⌨️ 快捷键说明

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