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

📄 ds18b20.lst

📁 keil环境下ds18b20温度检测1602显示
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   DS18B20                                                               07/20/2007 17:26:22 PAGE 4   

 180   2      
 181   2              temp3=temp3|high;
 182   2              temp3=temp3&0x00ff;
 183   2              temp1=temp3<<8;
 184   2              //temp1=temp3;
 185   2      
 186   2              temp1=temp1|low;
 187   2              
 188   2              temp1=(temp1^0xffff);
 189   2              temp1=temp1+1;   //取反加1
 190   2              low=temp1&0x000f;
 191   2              high=temp1>>4;
 192   2              
 193   2          
 194   2              process(high,low);
 195   2      
 196   2              }
 197   1              else
 198   1              {
 199   2      
 200   2                      flag=0;          //zhen
 201   2                      temp1=high;
 202   2                      temp2=low;
 203   2                      temp1=temp1<<4;
 204   2                      temp2=temp2>>4;
 205   2                      temp3=temp1|temp2;
 206   2                      high=temp3;
 207   2                      low=low&0x0f;
 208   2                      process(high,low);
 209   2              
 210   2              }
 211   1      }
 212          /*************************************************************
 213          **功能:数值处理函数                                                                                      **
 214          **参数:无返回                                                                                           **
 215          *************************************************************/
 216          void process(uchar high,uchar low)
 217          {
 218   1               uint temp1;
 219   1               uchar i;
 220   1               temp1=low*625;
 221   1           xiaoshu_temp[0]=temp1/1000+'0';
 222   1               /*xiaoshu_temp[1]=temp1/100%10+'0';
 223   1               xiaoshu_temp[2]=temp1%100/10+'0';
 224   1               xiaoshu_temp[3]=temp1%10+'0';
 225   1               xiaoshu_temp[1]='\0';
 226   1               dot_dis=1;
 227   1                      if(xiaoshu_temp[3]=='0')
 228   1                      {
 229   1                              xiaoshu_temp[3]='\0';
 230   1                              if(xiaoshu_temp[2]=='0')
 231   1                                      {
 232   1                                              xiaoshu_temp[2]='\0';
 233   1                                              if(xiaoshu_temp[1]=='0')
 234   1                                              {
 235   1                                                      xiaoshu_temp[1]='\0';
 236   1                                                      if(xiaoshu_temp[0]=='0')
 237   1                                                      {
 238   1                                                              xiaoshu_temp[0]='\0';
 239   1                                                              dot_dis=0;
 240   1                                                      }
 241   1                                                      else
C51 COMPILER V7.50   DS18B20                                                               07/20/2007 17:26:22 PAGE 5   

 242   1                                                              dot_dis=1;
 243   1                                                      
 244   1                                                              
 245   1                                              }
 246   1                                      }
 247   1                                              
 248   1                      }*/
 249   1              
 250   1               
 251   1               zhen_temp[0]=high/100+'0';
 252   1               zhen_temp[1]=(high%100)/10+'0';
 253   1               zhen_temp[2]=high%10+'0';
 254   1               zhen_temp[3]='\0';
 255   1               for(i=0;i<2;i++)
 256   1                      if(zhen_temp[0]=='0')
 257   1                              {
 258   2                              zhen_temp[0]=zhen_temp[1];
 259   2                              zhen_temp[1]=zhen_temp[2];
 260   2                              zhen_temp[2]='\0';
 261   2                              }
 262   1                      else
 263   1                              break;
 264   1      } 
 265          /****************************************/
 266          //serial_set func
 267          void serial_set(void)
 268          {
 269   1              
 270   1              SCON=0x50;
 271   1              TMOD=TMOD&0x0f;
 272   1              TMOD=TMOD|0x20;
 273   1              TH1=0xfd;
 274   1              TL1=0xfd;    
 275   1      
 276   1              TR1=1;
 277   1              TI=1;  //用PRINTF时,TI要置1
 278   1      }
 279          /*************************************************************
 280          **功能:读序列号子程序                                                                           **
 281          **参数:无返回                                                                                          **
 282          *************************************************************/
 283          /*uchar * read_rom()
 284          {
 285                  uchar rom[8],i;
 286                  ds18b20_init();
 287                  ds18b20_writecommand(0x33);
 288                  for(i=8;i>0;i--)
 289                  {
 290                          rom[i-1]=ds18b20_readdata();
 291                  }
 292                  return &rom[0];
 293          }*/     
 294          /*************************************************************
 295          **功能:序列号匹配子程序                                                                         **
 296          **参数:无返回                                                                                          **
 297          *************************************************************/
 298          bit match_rom(uchar *rom)
 299          {
 300   1              uchar i;
 301   1              ds18b20_init();
 302   1              ds18b20_writecommand(0x55);
 303   1              for(i=8;i>0;i--)
C51 COMPILER V7.50   DS18B20                                                               07/20/2007 17:26:22 PAGE 6   

 304   1              {
 305   2                      ds18b20_writecommand(*(rom+i-1));
 306   2              //      rom++;
 307   2              }
 308   1              return 1;
 309   1      }       
 310          /************************************************************
 311          **功能:实现温度报警                                       **
 312                                                                     **
 313          ************************************************************/
 314          char temperature_process1(uchar low,uchar high)
 315          {
 316   1              uint temp1,temp2,temp3;
 317   1              if(high&0x80)//判断正负
 318   1              {
 319   2              flag=1;
 320   2      
 321   2              temp3=temp3|high;
 322   2              temp3=temp3&0x00ff;
 323   2              temp1=temp3<<8;
 324   2              //temp1=temp3;
 325   2      
 326   2              temp1=temp1|low;
 327   2              
 328   2              temp1=(temp1^0xffff);
 329   2              temp1=temp1+1;   //取反加1
 330   2              low=temp1&0x000f;
 331   2              high=temp1>>4;
 332   2              if(high<20||high>80)
 333   2          return (1);
 334   2              }
 335   1              else
 336   1              {
 337   2      
 338   2                      flag=0;          //zhen
 339   2                      temp1=high;
 340   2                      temp2=low;
 341   2                      temp1=temp1<<4;
 342   2                      temp2=temp2>>4;
 343   2                      temp3=temp1|temp2;
 344   2                      high=temp3;
 345   2                      low=low&0x0f;
 346   2                      if(high<20||high>80)
 347   2              return (1); 
 348   2              }
 349   1      }
 350          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    552    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      9      11
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      2    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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