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

📄 ds18b20.lst

📁 此程序用的时钟芯片为12887
💻 LST
字号:
C51 COMPILER V7.50   DS18B20                                                               09/23/2008 20:05:37 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE DS18B20
OBJECT MODULE PLACED IN DS18B20.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE DS18B20.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*************************
   2          函数名:DS18B20
   3          功能:发送复位和初始化
   4                读数据
   5                    写数据
   6          **************************/
   7          void dsreset(void)       //发送复位和初始化
   8          {
   9   1        uint i;
*** ERROR C202 IN LINE 9 OF DS18B20.C: 'uint': undefined identifier
*** ERROR C141 IN LINE 9 OF DS18B20.C: syntax error near 'i'
  10   1        DS=0;
*** ERROR C202 IN LINE 10 OF DS18B20.C: 'DS': undefined identifier
  11   1        i=103;
*** ERROR C202 IN LINE 11 OF DS18B20.C: 'i': undefined identifier
  12   1        while(i>0)i--;  //延时
*** ERROR C202 IN LINE 12 OF DS18B20.C: 'i': undefined identifier
*** ERROR C202 IN LINE 12 OF DS18B20.C: 'i': undefined identifier
  13   1        DS=1;
*** ERROR C202 IN LINE 13 OF DS18B20.C: 'DS': undefined identifier
  14   1        i=4;
*** ERROR C202 IN LINE 14 OF DS18B20.C: 'i': undefined identifier
  15   1        while(i>0)i--;
*** ERROR C202 IN LINE 15 OF DS18B20.C: 'i': undefined identifier
*** ERROR C202 IN LINE 15 OF DS18B20.C: 'i': undefined identifier
  16   1      }
  17          
  18          bit tmpreadbit(void)       //读取数据的一位
  19          {
  20   1         uint i;
*** ERROR C202 IN LINE 20 OF DS18B20.C: 'uint': undefined identifier
*** ERROR C141 IN LINE 20 OF DS18B20.C: syntax error near 'i'
  21   1         bit dat;
*** ERROR C141 IN LINE 21 OF DS18B20.C: syntax error near 'bit'
*** ERROR C202 IN LINE 21 OF DS18B20.C: 'dat': undefined identifier
  22   1         DS=0;i++;          //i++ for delay
*** ERROR C202 IN LINE 22 OF DS18B20.C: 'DS': undefined identifier
*** ERROR C202 IN LINE 22 OF DS18B20.C: 'i': undefined identifier
  23   1         DS=1;i++;i++;
*** ERROR C202 IN LINE 23 OF DS18B20.C: 'DS': undefined identifier
*** ERROR C202 IN LINE 23 OF DS18B20.C: 'i': undefined identifier
*** ERROR C202 IN LINE 23 OF DS18B20.C: 'i': undefined identifier
  24   1         dat=DS;
*** ERROR C202 IN LINE 24 OF DS18B20.C: 'dat': undefined identifier
  25   1         i=8;while(i>0)i--;
*** ERROR C202 IN LINE 25 OF DS18B20.C: 'i': undefined identifier
*** ERROR C202 IN LINE 25 OF DS18B20.C: 'i': undefined identifier
*** ERROR C202 IN LINE 25 OF DS18B20.C: 'i': undefined identifier
  26   1         return (dat);
*** ERROR C202 IN LINE 26 OF DS18B20.C: 'dat': undefined identifier
  27   1      }
  28          
  29          uchar tmpread(void)   //读一个字节
*** ERROR C129 IN LINE 29 OF DS18B20.C: missing ';' before 'tmpread'
  30          {
C51 COMPILER V7.50   DS18B20                                                               09/23/2008 20:05:37 PAGE 2   

  31            uchar i,j,dat;
  32            dat=0;
  33            for(i=1;i<=8;i++)
  34            {
  35              j=tmpreadbit();
  36              dat=(j<<7)|(dat>>1);   //读出的数据最低位在最前面,这样刚好一个字节在DAT里
  37            }
  38            return(dat);
  39          }
  40          
  41          void tmpwritebyte(uchar dat)   //write a byte to ds18b20
  42          {
  43              uint i;
  44              uchar j;
  45              bit testb;
  46              for(j=1;j<=8;j++)
  47              {
  48                  testb=dat&0x01;
  49                  dat=dat>>1;
  50                  if(testb)     //write 1
  51                  {
  52                          DS=0;
  53                      i++;i++;
  54                          DS=1;
  55                      i=8;while(i>0)i--;
  56                  }
  57                  else
  58                  {
  59                      DS=0;       //write 0
  60                      i=8;while(i>0)i--;
  61                          DS=1;
  62                      i++;i++;
  63                  }
  64              }
  65          }
  66          
  67          void tmpchange(void)  //DS18B20 begin change
  68          {
  69              dsreset();
  70              delay(1);
  71              tmpwritebyte(0xcc);  // address all drivers on bus
  72              tmpwritebyte(0x44);  //  initiates a single temperature conversion
  73          }
  74          
  75          void tmp()               //读取温度
  76          {
  77              float tt;
  78              uchar a,b;
  79              dsreset(); //复位
  80              delay(1);
  81              tmpwritebyte(0xcc);   //跳过序列号命令
  82              tmpwritebyte(0xbe);   //发转换命令
  83              a=tmpread();  //读取低位温度
  84              b=tmpread();  //读取高位温度
  85              temp=b;
  86              temp<<=8;             //two byte  compose a int variable
  87              temp=temp|a;
  88              tt=temp*0.0625;
  89              temp=tt*10+0.5;
  90          //      return temp;
  91          }
  92          
C51 COMPILER V7.50   DS18B20                                                               09/23/2008 20:05:37 PAGE 3   

  93          void write_tmp(uchar add2,uchar date)  //写温度
  94          {
  95              uchar bai,shi,ser;
  96              ser=temp/10;
  97              SBUF=ser;
  98              bai=temp/100;
  99              shi=temp%100/10;
 100              write_com(0x80+0x40+add2);
 101              write_date(0x30+bai);
 102              write_date(0x30+shi);
 103          }
 104          void write_tmp1 (uchar add3,uchar date)  //写温度小数点后一位
 105          {
 106              uchar ge,ser;
 107              ser=temp/10;
 108              SBUF=ser;
 109              ge=temp%10;
 110              write_com(0x80+0x40+add3);
 111              write_date(0x30+ge);
 112          }
 113          

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

⌨️ 快捷键说明

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