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

📄 search.lst

📁 一个温度采集系统的单片机程序与WINDOWS 串口通信程序
💻 LST
字号:
C51 COMPILER V7.00  SEARCH                                                                 06/13/2005 14:42:00 PAGE 1   


C51 COMPILER V7.00, COMPILATION OF MODULE SEARCH
OBJECT MODULE PLACED IN Search.OBJ
COMPILER INVOKED BY: C:\PROGRA~1\KEILC5~1\C51\BIN\c51.exe Search.c DB OE SMALL ROM(LARGE)

stmt level    source

   1          #include<stdio.h>
   2          #include<reg51.h>
   3          #include<transmit_data_h.h>
   4          #include<iicrount_h.h>
*** WARNING C236 IN LINE 4 OF IICROUNT_H.H: '_wradr': different length of parameter lists
*** WARNING C236 IN LINE 5 OF IICROUNT_H.H: '_rdadr': different length of parameter lists
*** WARNING C236 IN LINE 6 OF IICROUNT_H.H: '_rdnbyt': different length of parameter lists
   5          #define FALSE 0
   6          #define TRUE  1
   7          
   8          extern   char data send_rom_flg;
   9          unsigned char  xdata FoundROM[64][8];
  10          ////////////////////////////////////////////////////////////////////////////
  11          //Global Variables
  12          unsigned char ROM[8];                   // ROM Bit
  13          unsigned char lastDiscrep ;     // last discrepancy
  14          unsigned char doneFlag ;                // Done flag      
  15          unsigned char numROMs;
  16          unsigned char data dowcrc ;
  17          
  18          // DELAY - with an 11.059MHz crystal.
  19          // Calling the routine takes about 24us, and then
  20          // each count takes another 16us.
  21          //
  22          void delay(unsigned char  useconds)
  23          {
  24   1      unsigned char data s;
  25   1      for (s=0; s<useconds;s++);
  26   1      }
  27          
  28          
  29          //////////////////////////////////////////////////////////////////////////////
  30          // ONE WIRE CRC
  31          //
  32          
  33          unsigned char code dscrc_table[] = {
  34          0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65,
  35          157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220,
  36          35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98,
  37          190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255,
  38          70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7,
  39          219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154,
  40          101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36,
  41          248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185,
  42          140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205,
  43          17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80,
  44          175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238,
  45          50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115,
  46          202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139,
  47          87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22,
  48          233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168,
  49          116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53
  50                                                          };
  51          
  52          
C51 COMPILER V7.00  SEARCH                                                                 06/13/2005 14:42:00 PAGE 2   

  53          
  54          
  55          unsigned char OWCrc( unsigned char x)
  56          {
  57   1              dowcrc = dscrc_table[dowcrc^x];
  58   1              return dowcrc;
  59   1      }
  60          
  61          
  62          
  63          
  64          
  65          
  66          // The Next function searches for the next device on the 1-wire bus. If
  67          // there are no more devices on the 1-wire then false is returned.
  68          //
  69          unsigned char Next(void)
  70          {
  71   1      unsigned char m = 1; // ROM Bit index
  72   1      unsigned char n = 0; // ROM Byte index
  73   1      unsigned char k = 1; // bit mask
  74   1      unsigned char x = 0;
  75   1      unsigned char discrepMarker = 0; // discrepancy marker
  76   1      unsigned char g; // Output bit
  77   1      unsigned char nxt; // return value
  78   1      unsigned char flag;
  79   1      
  80   1      nxt = FALSE; // set the next flag to false
  81   1      //dowcrc = 0; // reset the dowcrc
  82   1      flag = OWReset(); // reset the 1-wire  flag=0 表示正常复位
  83   1      
  84   1              if(flag||doneFlag) // no parts -> return false
  85   1              {
  86   2                      lastDiscrep = 0; // reset the search
  87   2                      return FALSE;
  88   2              }
  89   1      OWWriteByte(0xF0); // send SearchROM command
  90   1      do
  91   1      // for all eight bytes
  92   1        {
  93   2              x = 0;
  94   2              if(OWReadBit()==1) x = 2;
  95   2              delay(6);
  96   2              if(OWReadBit()==1) x |= 1; // and its complement
  97   2              if(x ==3) // there are no devices on the 1-wire
  98   2              break;
  99   2              else
 100   2              {
 101   3                      if(x>0) // all devices coupled have 0 or 1
 102   3                      g = x>>1; // bit write value for search
 103   3                      else
 104   3                      {
 105   4                      // if this discrepancy is before the last
 106   4                      // discrepancy on a previous Next then pick
 107   4                      // the same as last time
 108   4                              if(m<lastDiscrep)
 109   4                              g = ((ROM[n]&k)>0);
 110   4                              else // if equal to last pick 1
 111   4                              g = (m==lastDiscrep); // if not then pick 0
 112   4                      // if 0 was picked then record
 113   4                      // position with mask k
 114   4                              if (g==0) discrepMarker = m;
C51 COMPILER V7.00  SEARCH                                                                 06/13/2005 14:42:00 PAGE 3   

 115   4                      }
 116   3                      if(g==1) // isolate bit in ROM[n] with mask k
 117   3                      ROM[n] |= k;
 118   3                      else
 119   3                      ROM[n] &= ~k;
 120   3                      OWWriteBit(g); // ROM search write
 121   3                      m++; // increment bit counter m
 122   3                      k = k<<1; // and shift the bit mask k
 123   3                      if(k==0) // if the mask is 0 then go to new ROM
 124   3                      { // byte n and reset mask
 125   4                      OWCrc(ROM[n]); // accumulate the CRC
 126   4                      n++; k++;
 127   4                      }
 128   3              }       
 129   2         }while(n<8); //loop until through all ROM bytes 0-7
 130   1      
 131   1              if(m<65||dowcrc) // if search was unsuccessful then
 132   1      //      if(m<65)
 133   1              lastDiscrep=0; // reset the last discrepancy to 0
 134   1              else
 135   1              {
 136   2              // search was successful, so set lastDiscrep,
 137   2              // lastOne, nxt
 138   2              lastDiscrep = discrepMarker;
 139   2              doneFlag = (lastDiscrep==0);
 140   2              nxt = TRUE; // indicates search is not complete yet, more
 141   2              // parts remain
 142   2              }
 143   1              return nxt;
 144   1      }
 145          
 146          
 147          
 148          // FIRST
 149          // The First function resets the current state of a ROM search and calls
 150          // Next to find the first device on the 1-wire bus.
 151          //
 152          unsigned char First(void)
 153          {
 154   1              lastDiscrep = 0; // reset the rom search last discrepancy global
 155   1              doneFlag = FALSE;
 156   1              return Next(); // call Next and return its return value
 157   1      }
 158          
 159          
 160          
 161          
 162          // FIND DEVICES
 163          void FindDevices(void)
 164          {
 165   1      unsigned char m;
 166   1      
 167   1        if(!send_rom_flg)
 168   1        {
 169   2              if(!OWReset()) //Begins when a presence is detected
 170   2              {
 171   3                      if(First()) //Begins when at least one part is found
 172   3                      {
 173   4                      numROMs=0;
 174   4                              do
 175   4                              {                               
 176   5                              for(m=0;m<8;m++)
C51 COMPILER V7.00  SEARCH                                                                 06/13/2005 14:42:00 PAGE 4   

 177   5                                      {
 178   6                                      FoundROM[numROMs][m]=ROM[m]; //Identifies ROM
 179   6                                      //number on found device
 180   6                                      }  
 181   5                              numROMs++;                           
 182   5                              }while (Next()&&(numROMs<64)); //Continues until no additional devices are found
 183   4                      }
 184   3              }
 185   2         }    
 186   1      send_rom_flg    =1;
 187   1      }
 188          
 189          
 190          
 191          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    351    ----
   CONSTANT SIZE    =    256    ----
   XDATA SIZE       =    512    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     12       7
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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