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

📄 12232.lst

📁 刚通过的1820温度显示程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
 526   2              p++;
 527   2          }
 528   1      }
 529          
 530          ////////////////////////////////////////////////////////////////////////////////
 531          //函数:void disp_one_ascii(uchar col,uchar layer,uchar ascii_code)
 532          //说明:显示单个ASCII码col-列;layer-上下行:1-上,0-下;ascii_code:所要显示德ASCCII码
 533          ////////////////////////////////////////////////////////////////////////////////
 534          void disp_one_ascii(uchar col,uchar layer,uchar ascii_code,uchar mode)
 535          {
 536   1      	uchar i;
 537   1      	for(i=0;i<16;i++)                //ASCII码显示占用16个字节
 538   1      	{   
 539   2      		if(mode)dot_buffer[i]=~ascii[(ascii_code-0x20)*16 + i];
*** ERROR C193 IN LINE 539 OF .\12232.C: '~': bad operand type
 540   2      	    else    dot_buffer[i]= ascii[(ascii_code-0x20)*16 + i]; 
*** ERROR C213 IN LINE 540 OF .\12232.C: left side of asn-op not an lvalue
 541   2      	}  
 542   1      	draw_bmp(col,layer,8,dot_buffer);
 543   1      }
 544          
 545          ////////////////////////////////////////////////////////////////////////////////
 546          //函数:void disp_ram_data(uchar col,uchar layer,uchar n,uchar mode)
 547          //说明:显示小于4个的十进制数字//修改缓冲区的大小可以扩展显示
C51 COMPILER V6.12  12232                                                                  04/19/2008 15:34:41 PAGE 10  

 548          ////////////////////////////////////////////////////////////////////////////////
 549          void disp_ram_data(uchar col,uchar layer,uchar n,uchar mode)
 550          {
 551   1           while(n--)
 552   1      	 {
 553   2      		if(mode)disp_one_ascii(col,layer,disp_buffer[n]+0x30,1);
 554   2      		else    disp_one_ascii(col,layer,disp_buffer[n]+0x30,0);
 555   2      		col += 8;
 556   2      	 }
 557   1      }
 558          
 559          ////////////////////////////////////////////////////////////////////////////////
 560          //函数:void dprintf(uchar col,uchar layer,uchar *ptr,uchar mode)
 561          //说明:ASCII(8*16) 和 汉字(16*16)显示函数
 562          ////////////////////////////////////////////////////////////////////////////////
 563          void dprintf(uchar col,uchar layer,uchar *ptr,uchar mode)
 564          {
 565   1      	uchar c1,c2;
 566   1      	uchar i,j,k;
 567   1      	uchar ulen;
 568   1      	//uchar ucol,ulayer,umode;
 569   1      	uchar ucol,ulayer;
 570   1          ulen = 0; 
 571   1      	ucol = col;   
 572   1      	ulayer = layer;
 573   1      	
 574   1      	while (ptr[ulen]!= 0)ulen++;		   //探测字串长度
 575   1          i=0;
 576   1      	while(i<ulen)
 577   1      	{
 578   2      		c1 = ptr[i];
 579   2      		c2 = ptr[i+1];
 580   2              //ASCII字符与汉字内码的区别在于128做分界;大于128的为汉字码
 581   2      		if(c1 <=128)					  //ASCII
 582   2      		{   
 583   3      		        if(mode)disp_one_ascii(ucol,ulayer,c1,1);
 584   3      				else    disp_one_ascii(ucol,ulayer,c1,0);
 585   3      				ucol+=8;
 586   3      				i++;                      //ASCII码的处理
 587   3      		}
 588   2      		else							  //中文
 589   2      		{
 590   3      			    for(j=0;j<sizeof(GB_16)/sizeof(GB_16[0]);j++)  				                        
*** WARNING C198 IN LINE 590 OF .\12232.C: sizeof returns zero
*** WARNING C198 IN LINE 590 OF .\12232.C: sizeof returns zero
*** WARNING C222 IN LINE 590 OF .\12232.C: div by zero
 591   3      			    {                         //查找定位当前汉字的点阵区
 592   4      				    if((c1 == GB_16[j].Index[0]) && (c2 == GB_16[j].Index[1]))
*** ERROR C200 IN LINE 592 OF .\12232.C: left side of '.' requires struct/union
 593   4      					break;
 594   4      			    }
 595   3      			    for(k=0;k<32;k++)
 596   3      				{   if(mode)dot_buffer[k]=~GB_16[j].Msk[k];
*** ERROR C200 IN LINE 596 OF .\12232.C: left side of '.' requires struct/union
 597   4      				    else    dot_buffer[k]= GB_16[j].Msk[k];
*** ERROR C200 IN LINE 597 OF .\12232.C: left side of '.' requires struct/union
 598   4      				}
 599   3      			    draw_bmp(ucol,ulayer,16,dot_buffer);
 600   3      			    ucol+=16;
 601   3      				i+=2;                     //中文的处理
 602   3      		}
 603   2      	}
C51 COMPILER V6.12  12232                                                                  04/19/2008 15:34:41 PAGE 11  

 604   1      }	
 605          
 606          
 607          void delay(uint x)   ////when crystal is 12M ,a*2+5 us  ,子程序调用要5us,while 就等于DJNZ指令
 608          { 
 609   1      while (x--);
 610   1      }
 611          
 612          bit reset(void)                //初始化18B20 
*** ERROR C141 IN LINE 612 OF .\12232.C: syntax error near '0xE2'
*** ERROR C141 IN LINE 612 OF .\12232.C: syntax error near 'void'
*** ERROR C141 IN LINE 612 OF .\12232.C: syntax error near ')'
 613          { 
 614              bit presence=0;      //定义一个应答信号     
 615              DQ=1; 
*** ERROR C231 IN LINE 615 OF .\12232.C: 'DQ': redefinition
*** ERROR C231 IN LINE 615 OF .\12232.C: 'DQ': redefinition
 616           	 DQ=0;
*** ERROR C279 IN LINE 616 OF .\12232.C: 'DQ': multiple initialization
*** ERROR C231 IN LINE 616 OF .\12232.C: 'DQ': redefinition
*** ERROR C231 IN LINE 616 OF .\12232.C: 'DQ': redefinition
 617               delay(80);                 //置总线为低电平并保持至少480us       
*** ERROR C141 IN LINE 617 OF .\12232.C: syntax error near '80'
 618              DQ=1;                //等电阻拉高总线并保持15-60us 
*** ERROR C279 IN LINE 618 OF .\12232.C: 'DQ': multiple initialization
*** ERROR C231 IN LINE 618 OF .\12232.C: 'DQ': redefinition
*** ERROR C231 IN LINE 618 OF .\12232.C: 'DQ': redefinition
 619             delay(5);     
*** ERROR C141 IN LINE 619 OF .\12232.C: syntax error near '5'
 620              presence=DQ;              //接受应答信号 
*** ERROR C279 IN LINE 620 OF .\12232.C: 'presence': multiple initialization
*** ERROR C231 IN LINE 620 OF .\12232.C: 'presence': redefinition
*** ERROR C247 IN LINE 620 OF .\12232.C: non-address/-constant initializer
 621             delay(13);                           //延时60-240us  
*** ERROR C141 IN LINE 621 OF .\12232.C: syntax error near '13'
 622              return(presence);         //返回应答信号 
*** ERROR C141 IN LINE 622 OF .\12232.C: syntax error near 'return'
 623          } 
*** ERROR C141 IN LINE 623 OF .\12232.C: syntax error near '}'
 624          
 625          /* 从DS18B20读出1个字节 */
 626          uchar read_byte(void)        //从18b20读一个字节.返回读到的内容
 627          {
 628   1          uchar i,j;
 629   1          j=0;                              
 630   1          for(i=0;i<8;i++)
 631   1           {
 632   2              j=j>>1;
 633   2              DQ=0;
 634   2              _nop_();                      //要求>1us,但又不能超过15us
 635   2              _nop_();
 636   2              DQ=1;                  //释放总线
 637   2              _nop_();
 638   2              _nop_();
 639   2              if(DQ)
 640   2              j|=0x80;
 641   2              delay(30); 
*** ERROR C267 IN LINE 641 OF .\12232.C: 'delay': requires ANSI-style prototype
 642   2           }
 643   1      	    return  (j);
 644   1       }
 645          
C51 COMPILER V6.12  12232                                                                  04/19/2008 15:34:41 PAGE 12  

 646          
 647          void write_byte(uchar val)  //向DS18B20写入1个字节 
 648          {
 649   1          uchar i;
 650   1          for(i=0;i<8;i++)
 651   1          {
 652   2              DQ=0;
 653   2              _nop_();                      //要求>1us,但又不能超过15us
 654   2              _nop_();
 655   2              if(0x01&val)
 656   2                   DQ=1;
 657   2              delay(30);                  //要求总时间在60-120us
 658   2              DQ=1;                  //释放总线
 659   2              _nop_();                      //要求>1us      
 660   2              val=val>>1;
 661   2          }    
 662   1      }
 663          
 664          /* 读取温度子程序       */
 665           get_temperature(void)
 666          {
 667   1          uchar msb;//高8位
 668   1          uchar lsb;//低8位
 669   1          reset();         /* 发送复位信号     */
*** ERROR C211 IN LINE 669 OF .\12232.C: call not to a function
 670   1          delay(20);
 671   1          write_byte(0xcc);          /* 跳过ROM          */
 672   1          write_byte(0x44);         /* 发送转换温度命令 */
 673   1          reset();
*** ERROR C211 IN LINE 673 OF .\12232.C: call not to a function
 674   1          delay(14);
 675   1          write_byte(0xcc);
 676   1          write_byte(0xBE);         /* 发送读memory命令 */
 677   1          lsb =read_byte();
 678   1          msb =read_byte();
 679   1          reset();
*** ERROR C211 IN LINE 679 OF .\12232.C: call not to a function
 680   1      if((msb&0xF0)>0) { flag=1;msb=~msb; lsb=~lsb+1;}//如果为负温度取反加1
 681   1      else  flag=0;
 682   1      table[0]=(msb<<4)|(lsb&0>>4);
*** ERROR C213 IN LINE 682 OF .\12232.C: left side of asn-op not an lvalue
 683   1      table[1]=((lsb<<4)*5)/128;// 小数点后两位.可做到后4位即0.0625为单位
*** ERROR C213 IN LINE 683 OF .\12232.C: left side of asn-op not an lvalue
 684   1      }
 685          
 686          main ()
 687          {
 688   1          get_temperature();
 689   1          while(1)
 690   1          {
 691   2               get_temperature();
 692   2              if (flag)
 693   2              {
 694   3               ;   
 695   3              }
 696   2              delay(10000);
 697   2          }
 698   1      }
 699          
 700          
 701          ////////////////////////////////////////////////////////////////////////////////
 702          ///////////////////////////////////////////////////////////////////////////////
C51 COMPILER V6.12  12232                                                                  04/19/2008 15:34:41 PAGE 13  

 703          /*
 704          void main(void)
 705          {	
 706             char i;
 707             uint  j;
 708          //   DDRC=0xF0;                           //C口高四位为输出控制端口
 709          //   DDRA=0xFF;                           //A口为数据线(一般为输出,仅在读LCD状态时为输入)
 710             for(i=0;i<10;i++);
 711          	for(j=1;j<10;j++);       //开机延时
 712             lcd_init();
 713             lcd_clr();
 714             while(1) 
 715          	{
 716          		for(i=121;i>0;i--)        //往左滚动输出
 717          				{
 718          			   lcd_clr();
 719          				dprintf((i+24),1,"太川单片机          欢迎光临",0);//第二步,调整数据使它达到要求10个空格刚刚好在中间
 720          			   dprintf((i-96),0,"单 HTTP://TCMCU.ICPCN.COM",0);
 721          			   //第一步,调整I-x使最后出现的达到要求,第一个字出现在后面也不要紧
 722          				delay_ms(200);
 723          				
 724          				}
 725              delay_ms(3000);
 726              lcd_clr();
 727              delay_ms(3000);
 728          	 for(i=121;i>0;i--)      //往左滚动输出
 729          				{
 730          			   lcd_clr();
 731          				dprintf((i+24),1,"太川单片机",0);
 732          			   dprintf(i,0,"电话:028-66021915",1); 
 733          			   delay_ms(200);
 734          					
 735          				}
 736          	   delay_ms(1000);
 737          		lcd_clr();delay_ms(200);
 738                      dprintf(24,1,"太川单片机",0);
 739          			   dprintf(0,0,"电话:028-66021915",1);
 740          		      delay_ms(200);
 741                lcd_clr();delay_ms(200);
 742                      dprintf(24,1,"太川单片机",0);
 743          			   dprintf(0,0,"电话:028-66021915",1);
 744          		      delay_ms(200);
 745          		lcd_clr();delay_ms(200);
 746                      dprintf(24,1,"太川单片机",0);
 747          			   dprintf(0,0,"电话:028-66021915",1);
 748          		      delay_ms(200);
 749          		lcd_clr();
 750          		      delay_ms(200);
 751          
 752          	
 753             
 754          	} 
 755          }*/

C51 COMPILATION COMPLETE.  3 WARNING(S),  32 ERROR(S)

⌨️ 快捷键说明

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