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

📄 search.lst

📁 一个温度采集系统的单片机程序与WINDOWS 串口通信程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.00  SEARCH                                                                 03/15/2005 14:34:07 PAGE 1   


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

stmt level    source

   1          //问题:二元数组在C51-ASM之间的参数传递?
   2          
   3          //外部扩展16k RAM划分:0000H~0FFFH 存放DS18B20 ID 4K
   4          //                           1000H~1FFFH存放温度超限DS18B20 ID 4K
   5          //                           2000H~2BFFH存放CRC参数     2K
   6          //                           2CFFH~33FFH                    2K
   7          //                           3400H~3FFFH存放温度数据  4K
   8          
   9          //外部扩展EEPROM划分: 0000H~0FFFH 存放DS18B20 ID 4K
  10          //                           1000H~1BFFH 存放温度超限DS18B20 ID 2K
  11          //                           1CFFH~1FFFH 用户RAM单元    2K
  12          //                           2000H~3FFFH 存放温度数据   8K      
  13          
  14          extern bit data send_rom_flg;
  15          
  16          #include<stdio.h>
  17          #include<reg51.h>
  18          #include<transmit_data_h.h>
  19          #define FALSE 0
  20          #define TRUE  1
  21          ////////////////////////////////////////////////////////////////////////////
  22          //Global Variables
  23          unsigned char ROM[8];                   // ROM Bit
  24          unsigned char lastDiscrep ;     // last discrepancy
  25          unsigned char doneFlag ;                // Done flag
  26          unsigned char data FoundROM[1][8] ; // table of found ROM codes
  27          //unsigned char data FoundROM_sub[1][8] ;         
  28          unsigned char numROMs;
  29          //unsigned char data dowcrc ;
  30          
  31          // DELAY - with an 11.059MHz crystal.
  32          // Calling the routine takes about 24us, and then
  33          // each count takes another 16us.
  34          //
  35          void delay(unsigned char  useconds)
  36          {
  37   1      unsigned char data s;
  38   1      for (s=0; s<useconds;s++);
  39   1      }
  40          
  41          
  42          //////////////////////////////////////////////////////////////////////////////
  43          // ONE WIRE CRC
  44          //
  45          /*
  46          unsigned char code dscrc_table[] = {
  47          0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65,
  48          157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220,
  49          35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98,
  50          190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255,
  51          70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7,
  52          219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154,
  53          101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36,
  54          248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185,
  55          140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205,
C51 COMPILER V7.00  SEARCH                                                                 03/15/2005 14:34:07 PAGE 2   

  56          17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80,
  57          175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238,
  58          50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115,
  59          202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139,
  60          87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22,
  61          233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168,
  62          116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53
  63                                                          };
  64          
  65          
  66          
  67          
  68          unsigned char OWCrc( unsigned char x)
  69          {
  70                  dowcrc = dscrc_table[dowcrc^x];
  71                  return dowcrc;
  72          }
  73          
  74          
  75          
  76          */
  77          
  78          
  79          // The Next function searches for the next device on the 1-wire bus. If
  80          // there are no more devices on the 1-wire then false is returned.
  81          //
  82          unsigned char Next(void)
  83          {
  84   1      unsigned char m = 1; // ROM Bit index
  85   1      unsigned char n = 0; // ROM Byte index
  86   1      unsigned char k = 1; // bit mask
  87   1      unsigned char x = 0;
  88   1      unsigned char discrepMarker = 0; // discrepancy marker
  89   1      unsigned char g; // Output bit
  90   1      unsigned char nxt; // return value
  91   1      bit data flag;
  92   1      
  93   1      nxt = FALSE; // set the next flag to false
  94   1      //dowcrc = 0; // reset the dowcrc
  95   1      flag = OWReset(); // reset the 1-wire  flag=0 表示正常复位
  96   1      
  97   1      if(flag||doneFlag) // no parts -> return false
  98   1      {
  99   2              lastDiscrep = 0; // reset the search
 100   2              return FALSE;
 101   2      }
 102   1      OWWriteByte(0xF0); // send SearchROM command
 103   1      do
 104   1      // for all eight bytes
 105   1        {
 106   2              x = 0;
 107   2              if(OWReadBit()==1) x = 2;
 108   2              delay(6);
 109   2              if(OWReadBit()==1) x |= 1; // and its complement
 110   2              if(x ==3) // there are no devices on the 1-wire
 111   2              break;
 112   2              else
 113   2              {
 114   3                      if(x>0) // all devices coupled have 0 or 1
 115   3                      g = x>>1; // bit write value for search
 116   3                      else
 117   3                      {
C51 COMPILER V7.00  SEARCH                                                                 03/15/2005 14:34:07 PAGE 3   

 118   4                      // if this discrepancy is before the last
 119   4                      // discrepancy on a previous Next then pick
 120   4                      // the same as last time
 121   4                              if(m<lastDiscrep)
 122   4                              g = ((ROM[n]&k)>0);
 123   4                              else // if equal to last pick 1
 124   4                              g = (m==lastDiscrep); // if not then pick 0
 125   4                      // if 0 was picked then record
 126   4                      // position with mask k
 127   4                              if (g==0) discrepMarker = m;
 128   4                      }
 129   3                      if(g==1) // isolate bit in ROM[n] with mask k
 130   3                      ROM[n] |= k;
 131   3                      else
 132   3                      ROM[n] &= ~k;
 133   3                      OWWriteBit(g); // ROM search write
 134   3                      m++; // increment bit counter m
 135   3                      k = k<<1; // and shift the bit mask k
 136   3                      if(k==0) // if the mask is 0 then go to new ROM
 137   3                      { // byte n and reset mask
 138   4      //              OWCrc(ROM[n]); // accumulate the CRC
 139   4                      n++; k++;
 140   4                      }
 141   3              }       
 142   2         }while(n<8); //loop until through all ROM bytes 0-7
 143   1      
 144   1      //      if(m<65||dowcrc) // if search was unsuccessful then
 145   1              if(m<65)
 146   1              lastDiscrep=0; // reset the last discrepancy to 0
 147   1              else
 148   1              {
 149   2              // search was successful, so set lastDiscrep,
 150   2              // lastOne, nxt
 151   2              lastDiscrep = discrepMarker;
 152   2              doneFlag = (lastDiscrep==0);
 153   2              nxt = TRUE; // indicates search is not complete yet, more
 154   2              // parts remain
 155   2              }
 156   1              return nxt;
 157   1      }
 158          
 159          
 160          
 161          // FIRST
 162          // The First function resets the current state of a ROM search and calls
 163          // Next to find the first device on the 1-wire bus.
 164          //
 165          unsigned char First(void)
 166          {
 167   1              lastDiscrep = 0; // reset the rom search last discrepancy global
 168   1              doneFlag = FALSE;
 169   1              return Next(); // call Next and return its return value
 170   1      }
 171          
 172          
 173          
 174          

⌨️ 快捷键说明

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