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

📄 main.lst

📁 51单片机的C语言编写的DS18B20的驱动程序
💻 LST
字号:
C51 COMPILER V7.09   MAIN                                                                  09/04/2008 21:28:03 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: R:\electronic\keilc51\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          //DELAY -with an 11.059MHz crystal
   2          //Calling the routine takes about 24us,and then 
   3          //each cout takes another 16 us
   4          //delay function
   5          void delay(int us)
   6          {
   7   1              int s;
   8   1              for(s=0;s<us;s++);
   9   1      }
  10          //reset function
  11          unsigned char ow_reset(void)
  12          {
  13   1              unsigned char presence;
  14   1              DQ=0;                   //pull DQ line low
*** ERROR C202 IN LINE 14 OF MAIN.C: 'DQ': undefined identifier
  15   1              delay(29);              //leave it low for 480us
  16   1              DQ=1;                   //allow line to return high
*** ERROR C202 IN LINE 16 OF MAIN.C: 'DQ': undefined identifier
  17   1              delay(3);               //wait for presence
  18   1              presence=DQ;    //get presence signal
*** ERROR C202 IN LINE 18 OF MAIN.C: 'DQ': undefined identifier
  19   1              delay(25);
  20   1              return(presence);//presence signal returned
  21   1      }                                       //presence=0,no part=1
  22          
  23          //read bit function
  24          unsigned char read_bit(void)
  25          {
  26   1              unsigned char i;
  27   1              DQ=0;                   //pull DQ low to start timeslot
*** ERROR C202 IN LINE 27 OF MAIN.C: 'DQ': undefined identifier
  28   1              DQ=1;                   //then return high
*** ERROR C202 IN LINE 28 OF MAIN.C: 'DQ': undefined identifier
  29   1              for(i=0;i<3;i++);       //delay 15 us from start of times lot
  30   1              return(DQ);             //return value of DQ line
*** ERROR C202 IN LINE 30 OF MAIN.C: 'DQ': undefined identifier
  31   1      }
  32          void write_bit(char bitval)
  33          {
  34   1              DQ=0;                   //pull DQ low to start timeslot
*** ERROR C202 IN LINE 34 OF MAIN.C: 'DQ': undefined identifier
  35   1              if(bitval==1)DQ=1;//return DQ high if write 1
*** ERROR C202 IN LINE 35 OF MAIN.C: 'DQ': undefined identifier
  36   1              delay(5);               //hold value for remainder of timeslot
  37   1              DQ=1;
*** ERROR C202 IN LINE 37 OF MAIN.C: 'DQ': undefined identifier
  38   1      }//Delay provides 16us per loop ,plus 24 us therefore
  39          //,delay(5)=104 us
  40          unsigned char read_byte(void)
  41          {
  42   1              unsigned char i;
  43   1              unsigned char value=0;
  44   1              for(i=0;i<8;i++){
  45   2                      if(read_bit())value|=0x01<<i;
  46   2      //reads byte in,one byte at a time and then shifts it left
C51 COMPILER V7.09   MAIN                                                                  09/04/2008 21:28:03 PAGE 2   

  47   2                      delay(6);//wait for rest os timeslot
  48   2              }
  49   1              return (value);
  50   1      }
  51          void write_byte(char val)
  52          {
  53   1              unsigned char i;
  54   1              unsigned char temp;
  55   1              for(i=0;i<8;i++){//writes byte,one bit at a time                
  56   2                      temp=val>>i;//shifts val right 'i' spaces
  57   2                      temp &=0x01;//copy that bit to temp
  58   2                      write_bit(temp);//write bit in temp into
  59   2              }
  60   1              delay(5);
  61   1      }

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

⌨️ 快捷键说明

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