版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、<p><b> 外文資料</b></p><p> 1-Wire Search Algorithm</p><p><b> Abstract</b></p><p> Dallas Semiconductor's 1-Wire® devices each have a 64-bit
2、unique registration number in read-only-memory (ROM).That is used to address them individually by a 1-Wire master in a 1-Wire network. If the ROM numbers of the slave devices on the 1-Wire network are not known, then usi
3、ng a search algorithm can discover them. This document explains the search algorithm in detail and provides an example implementation for rapid integration. This algorithm is valid for all current and future devices that
4、 f</p><p> Table 1 Bit Unique ROM 'Registration' Number.</p><p> Search Algorithm</p><p> The search algorithm is a binary tree search where branches are followed until a
5、 device ROM number, or leaf, is found. Subsequent searches then take the other branch paths until all of the leaves present are discovered.</p><p> The search algorithm begins with the devices on the 1-Wire
6、 being reset using the reset and presence pulse sequence. If this is successful then the 1-byte search command is sent. The search command readies the 1-Wire devices to begin the search.</p><p> There are t
7、wo types of search commands. The normal search command (0F0 hex) will perform a search with all devices participating. The alarm or conditional search command (0EC hex) will perform a search with only the devices that ar
8、e in some sort of alarm state. This reduces the search pool to quickly respond to devices that need attention.</p><p> Following the search command, the actual search begins with all of the participating de
9、vices simultaneously sending the first bit (least significant) in their ROM number (also called registration number). (See Figure 1.) As with all 1-Wire communication, the 1-Wire master starts every bit whether it is dat
10、a to be read or written to the slave devices. Due to the characteristics of the 1-Wire, when all devices respond at the same time, the result will be a logical AND of the bits sent. After the d</p><p> Tabl
11、e 2 Bit Search Information</p><p> According to the search algorithm, the 1-Wire master must then send a bit back to the participating devices. If the participating device has that bit value, it continues
12、participating. If it does not have the bit value, it goes into a wait state until the next 1-Wire reset is detected. This 'read two bits' and 'write one bit' pattern is then repeated for the remaining 63
13、bits of the ROM number (see Table 2). In this way the search algorithm forces all but one device to go into this wait state. A</p><p> On examination of Table 1, it is obvious that if all of the participati
14、ng devices have the same value in a bit position then there is only one choice for the branch path to be taken. The condition where no devices are participating is an atypical situation that may arise if the device being
15、 discovered is removed from the 1- Wire during the search. If this situation arises then the search should be terminated and a new search could be done starting with a 1-Wire reset. </p><p> Table 3 Wire Ma
16、ster and Slave Search Sequence</p><p> The condition where there are both 0s and 1s in the bit position is called a discrepancy and is the key to finding devices in the subsequent searches. The search algor
17、ithm specifies that on the first pass, when there is a discrepancy (bit/complement = 0/0), the '0' path is taken. Note that this is arbitrary for this particular algorithm. Another algorithm could be devised to u
18、se the '1' path first. The bit position for the last discrepancy is recorded for use in the next search. Table 3 describe</p><p> Table 4 Search Path Direction</p><p> The search algo
19、rithm also keeps track of the last discrepancy that occurs within the first eight bits of the algorithm. The first eight bits of the 64-bit registration number is a family code. As a result, the devices discovered during
20、 the search are grouped into family types. The last discrepancy within that family code can be used to selectively skip whole groups of 1-Wire devices. See the description of ADVANCED SEARCH VARIATIONS for doing selectiv
21、e searches. The 64-bit ROM number also contai</p><p> Id_bit—the first bit read in a bit search sequence. This bit is the AND of all of the id_bit_number bits of the devices that are still participating in
22、the search.</p><p> cmp_id_bit—the complement of the id_bit .This bit is the AND of the complement of all of the id_bit_number bits of the devices that are still participating in the search.</p><
23、p> Id_bit_number—the ROM bit number 1 to 64 currently being searched.</p><p> LastDeviceFlag—flag to indicate previous search was the last device.</p><p> LastDiscrepancy—bit index that id
24、entifies from which bit the (next) search discrepancy check should start.</p><p> LastFamilyDiscrepancy—bit index that identifies the LastDiscrepancy within the first 8-bit family code of ROM number.</p&
25、gt;<p> last_zero—bit position of the last zero written where there was a discrepancy.</p><p> ROM_NO—8-byte buffer that contains the current ROM registration number discovered.</p><p>
26、 search_direction—bit value indicating the direction of the search. All devices with this bit stay in the search and the rest go into a wait state for a 1-Wire reset.</p><p> There are two basic types of o
27、perations that can be performed by using the search algorithm by manipulating the LastDiscrepancy, LastFamilyDiscrepancy, LastDeviceFlag, and ROM_NO register values (see Table 4). These operations concern basic discovery
28、 of the ROM numbers of 1-Wire devices.First</p><p> The 'FIRST' operation is to search on the 1-Wire for the first device. This is performed by setting LastDiscrepancy, LastFamilyDiscrepancy, and La
29、stDeviceFlag to zero and then doing the search. The resulting ROM number can then be read from the ROM_NO register. If no devices are present on the 1- Wire the reset sequence will not detect a presence and the search is
30、 aborted.Next</p><p> The 'NEXT' operation is to search on the 1-Wire for the next device. This search is usually performed after a 'FIRST' operation or another 'NEXT' operation. It
31、is performed by leaving the state unchanged from the previous search and performing another search. The resulting ROM number can then be read from the ROM_NO register. If the previous search was the last device on the 1-
32、Wire then the result will be FALSE and the condition will be set to execute a 'FIRST' with the next call of the search a</p><p> The following goes through a simple search example with three devices
33、. For illustration, this example assumes devices with a 2-bit ROM number only.</p><p> Search Example</p><p> (for simplicity the family discrepancy register and tracking has been left out of
34、this example)</p><p><b> FIRST</b></p><p> LastDiscrepancy = LastDeviceFlag = 0</p><p> Do 1-Wire reset and wait for presence pulse ,if no presence pulse then done<
35、;/p><p> ?id_bit_number = 1, last_zero = 0</p><p> Send search command ,0F0 hex</p><p> Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0</p><p&g
36、t; Read complement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0</p><p> Since id_bit_number > LastDiscrepancy,then search_direction = 0, last_zero = 1</p><p>
37、; Send search_direction bit of 0 , both Device A and C go into wait state</p><p> Increment id_bit_number to 2</p><p> Read second bit id_bit : 0(Device B) = 0</p><p> Read comp
38、lement of second bit cmp_id_bit : 1 (Device B) = 1</p><p> Since bit and complement are different then search_direction = id_bit</p><p> Send search_direction bit of 0 ,Device B is discovered
39、with ROM_NO of ‘00’ and is now selected</p><p> LastDiscrepancy = last_zero</p><p><b> NEXT</b></p><p> Do 1-Wire reset and wait for presence pulse ,if no presence pu
40、lse then done</p><p> id_bit_number = 1, last_zero = 0</p><p> Send search command ,0F0 hex</p><p> Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0<
41、/p><p> Read complement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0</p><p> Since id_bit_number = LastDiscrepancy then search_direction = 1</p><p>
42、Send search_direction bit of 1 , Device B goes into wait state</p><p> Increment id_bit_number to 2</p><p> Read second bit id_bit : 0(Device A) AND 1(Device C) = 0</p><p> Read
43、complement of second bit cmp_id_bit : 1(Device A) AND 0(Device C) = 0</p><p> Since id_bit_number > LastDiscrepancy,then search_direction = 0, last_zero = 2</p><p> Send search_direction bi
44、t of 0 , Device C goes into wait state</p><p> Device A is discovered with ROM_NO of ‘01’ and is now selected</p><p> LastDiscrepancy = last_zero</p><p><b> NEXT</b>&
45、lt;/p><p> Do 1-Wire reset and wait for presence pulse ,if no presence pulse then done</p><p> id_bit_number = 1, last_zero = 0</p><p> Send search command ,0F0 hex</p><p
46、> Read first bit id_bit : 1 (Device A) AND 0 (Device B) AND 1 (Device C) = 0</p><p> Read complement of first bit cmp_id_bit : 0 (Device A) AND 1 (Device B) AND 0 (Device C) = 0</p><p> Si
47、nce id_bit_number < LastDiscrepancy then search_direction = ROM_NO (first bit) = 1</p><p> Send search_direction bit of 1 , Device B goes into wait state</p><p> Increment id_bit_number to
48、2</p><p> Read second bit id_bit : 0(Device A) AND 1(Device C) = 0</p><p> Read complement of second bit cmp_id_bit : 1(Device A) AND 0(Device C) = 0</p><p> Since id_bit_number
49、= LastDiscrepancy,then search_direction = 1</p><p> Send search_direction bit of 1 , Device A goes into wait state</p><p> Device C is discovered with ROM_NO of ‘11’ and is now selected</p&
50、gt;<p> LastDiscrepancy = last_zero which is 0 so LastDeviceFlag = TRUE</p><p><b> NEXT</b></p><p> LastDeviceFlag is true so return FALSE</p><p> ?LastDiscre
51、pancy = LastDeviceFlag = 0</p><p> Advanced Search Variations</p><p> There are three advanced search variations using the same state information, namely LastDiscrepancy, LastFamilyDiscrepancy
52、, LastDeviceFlag, and ROM_NO. These variations allow specific family types to be targeted or skipped and device present verification (see Table 4).</p><p><b> Verify</b></p><p> Th
53、e 'VERIFY' operation verifies if a device with a known ROM number is currently connected to the 1- Wire. It is accomplished by supplying the ROM number and doing a targeted search on that number to verify it is p
54、resent. First, set the ROM_NO register to the known ROM number. Then set the LastDiscrepancy to 64 (40 hex) and the LastDeviceFlag to 0. Perform the search operation and then read the ROM_NO result. If the search was suc
55、cessful and the ROM_NO remains the ROM number that was being searc</p><p> Target Setup</p><p> The 'TARGET SETUP' operation is a way to preset the search state to first find a particu
56、lar family type. Each 1-Wire device has a one byte family code embedded within the ROM number (see Figure 1). This family code allows the 1-Wire master to know what operations this device is capable of. If there are mult
57、iple devices on the 1-Wire it is common practice to target a search to only the family of devices that are of interest. To target a particular family, set the desired family code byte into the</p><p> Famil
58、y Skip Setup</p><p> The 'FAMILY SKIP SETUP' operation sets the search state to skip all of the devices that have the family code that was found in the previous search. This operation can only be pe
59、rformed after a search. It is accomplished by copying the LastFamilyDiscrepancy into the LastDiscrepancy and clearing out the LastDeviceFlag. The next search will then find devices that come after the current family code
60、. If the current family code group was the last group in the search then the search will return with th</p><p> Table5 Search Variations State Setup</p><p> Conclusion</p><p> T
61、he supplied search algorithm allows the discovery of the individually unique ROM numbers from any given group of 1-Wire devices. This is essential to any multidrop 1-Wire application. With the ROM numbers in hand, each 1
62、-Wire device can be selected individually for operations. This document also discussed search variations to find or skip particular 1-Wire device types. See Appendix for a 'C' code example implementation of the s
63、earch and all of the search variations.</p><p><b> 中文譯文</b></p><p> 1-Wire 搜索算法</p><p><b> 緒論</b></p><p> Dallas Semiconductor的每片1-Wire®
64、;器件都有唯一的64位注冊碼它存儲在只讀存儲器(ROM)中。在1-Wire網(wǎng)絡中注冊碼用于1-Wire主機對從機器件進行逐一尋址。如果1-Wire網(wǎng)絡中從機器件的ROM 碼是未知的,可以通過搜索算法來找到此碼。本文不僅詳細地解釋了搜索算法,而且還提供了實現(xiàn)快速整合的例程該算法適用于任何具有1-Wire接口特性的現(xiàn)有產(chǎn)品及未來產(chǎn)品。</p><p> 表1 64 位唯一的ROM 注冊碼</p>&
65、lt;p><b> 搜索算法</b></p><p> 搜索算法采用的是二叉樹型結(jié)構(gòu),搜索過程沿各分節(jié)點進行,直到找到器件的ROM碼即葉子為止;后續(xù)的搜索操作沿著節(jié)點上的其它路徑進行,按照同樣的方式直到找到總線上的所有器件代碼。</p><p> 搜索算法首先通過復位(Reset)和在線應答脈沖(Presence Pulse)時隙將1-Wire總線上的所有
66、器件復位;成功地執(zhí)行該操作后,發(fā)送1個字節(jié)的搜索命令;搜索命令使1-Wire器件準備、就緒開始進行搜索操作。</p><p> 搜索命令分為兩類標準搜索命令(0F0H)用來搜索連接到網(wǎng)絡中所有器件;報警或有條件搜索命令(0ECH)只用來搜索那些處于報警狀態(tài)下的器件,這種方式縮小了搜索范圍,可以快速查找到所需要注意的器件。</p><p> 搜索命令發(fā)出之后,開始實際的搜索過程。首先總線
67、上的所有從機器件同時發(fā)送ROM 碼(也叫注冊碼)中的第一位(最低有效位)(參見圖1)。與所有的1-Wire通信一樣無論是讀取數(shù)據(jù)還是向從機器件寫數(shù)據(jù),都由1-Wire主機啟動每一位操作。按照1-Wire的特性,當所有從機器件同時應答主機時,結(jié)果相當于全部發(fā)送數(shù)據(jù)位的邏輯AND;從機發(fā)送其ROM碼的第一位后,主機啟動下一位操作、接著從機發(fā)送第一位數(shù)據(jù)的補碼;從兩次讀到的數(shù)據(jù)位可以對ROM碼的第一位做出幾種判斷(參見表2)。</p&g
68、t;<p> 按照搜索算法的要求,1-Wire主機必須向總線上的從機發(fā)回一個指定位;如果從機器件中ROM碼的當前位的值與該數(shù)據(jù)位匹配,則繼續(xù)參與搜索過程;若從機器件的當前位與之不匹配,則該器件轉(zhuǎn)換到等待狀態(tài),并保持等待狀態(tài)直到下一個1-Wire復位信號到來。其余63位ROM 碼的搜索依然按照這種‘讀兩位’、‘寫一位’的模式進行重復操作(參見表3)。</p><p><b> 表2 檢
69、索信息位</b></p><p> 按照這種搜索算法進行下去,最終除了一個從機器件外所有從機將進入等待狀態(tài),經(jīng)過最后一輪檢測,就可得到最后保留(未進入等待狀態(tài))器件的ROM碼。在后續(xù)搜索過程中,選用不同的路徑(或分支)來查找其它器件的ROM碼。需要注意的是本文ROM碼的數(shù)據(jù)位用第1位(最低有效位)到第64位(最高有效位)表示,而不是我們常用的那種第0位到第63位的模式;這樣設置允許將差異位置記數(shù)器初
70、始值置為0,為以后的比較提供了方便。</p><p> 表3 1-Wire 主機和從機的搜索過程</p><p> 從表4 可以看出:如果所有總線上的器件在當前位具有相同值,那么只有一條分支路徑可選;總線上沒有器件響應的情況是一種異常狀態(tài),可能是要查找的器件在搜尋過程中與1-Wire 總線脫離。如果當前位既有0也有1,這種情況稱為位值差異,它對在后續(xù)搜索過程中查找器件起關(guān)鍵作用。搜
71、索算法指定在第一輪查詢中若出現(xiàn)差異(數(shù)據(jù)位/補碼 = 0/0), 則選用‘0’路徑。注意:這一點是由本文檔中介紹的特定算法決定的,其它算法中或許首先選用‘1’路徑。記錄最后一次值差異的位置以供下一次搜索使用,表3列出了出現(xiàn)值差異時路徑的選取情況。</p><p> 表4 搜索路徑方向</p><p> 搜索算法計算還對最初8位過程中出現(xiàn)的最后一次位差異保持跟蹤;64位注冊碼的前8位是
72、家族碼,在器件的搜索過程中可以按照其家族碼進行分類。記錄家族碼的最后一次差異可以用于有選擇性地跳過1-Wire器件的整個分組。如需進行選擇性地搜索,可參考關(guān)于高級變量搜索的詳細解釋。64位ROM碼中包含8位循環(huán)冗余校驗碼(CRC);CRC值用于驗證是否搜索到正確的ROM碼注釋對實例中出現(xiàn)的符號進行了說明;在本文檔的源代碼附錄中也將用到這些專用符號。</p><p><b> 注釋:</b>
73、</p><p> id_bit——在位搜索中第一次讀取的值,該位是搜索過程中所有應答器件的id_bit_number 位的邏輯AND</p><p> cmp_id_bit——id_bit 位的補碼,該位是搜索過程中所有應答器件的id_bit_number位的補碼的邏輯AND</p><p> id_bit_number——記錄當前搜索是1到64位ROM碼中
74、哪一位的量</p><p> LastDeviceFlag——指明前一次搜索到的已是最后一個器件的標志位</p><p> LastDiscrepancy ——位指針指明下次搜索從哪個值差異位開始</p><p> LastFamilyDiscrepancy——位指針。用來指明LastDiscrepancy是否是在ROM碼中前8位家族碼內(nèi)和其位置</p&
75、gt;<p> last_zero——上次被寫入0的值差異位的位置</p><p> ROM_NO——記錄當前正在查找的ROM,注冊碼的8字節(jié)緩沖器</p><p> search_direction——位變量其值用來指明搜索方向具有此數(shù)據(jù)位規(guī)定值的所有器件繼續(xù)響應搜索操作其它器件轉(zhuǎn)入等待狀態(tài)直到下一次1-Wire復位搜</p><p> 索算
76、法通過對LastDiscrepancy、LastFamilyDiscrepancy、LastDeviceFlag 和</p><p> ROM_NO 值(參見表4)的處理利用上述流程實現(xiàn)了兩個不同類型的搜索操作;這兩個操作是搜索1-Wire 器件ROM 碼的基礎。</p><p><b> FIRST</b></p><p> ‘FIRS
77、T’操作是搜索1-Wire總線上的第一個從機器件。該操作是通過將LastDiscrepancy、</p><p> LastFamilyDiscrepancy和LastDeviceFlag置零,然后進行搜索完成的。最后ROM碼從ROM_NO</p><p> 寄存器中讀出。若1-Wire總線上沒有器件,復位序列就檢測不到應答脈沖,搜索過程中止。</p><p>
78、<b> NEXT</b></p><p> ‘NEXT’操作是搜索1-Wire總線上的下一個從機器件;一般情況下此搜索操作是在‘FIRST’</p><p> 操作之后或上一次‘NEXT’操作之后進行;保持上次搜索后這些值的狀態(tài)不變、執(zhí)行又一次搜索即可實現(xiàn)‘NEXT’操作。之后從ROM_NO寄存器中來讀出新一個ROM碼。若前一次搜索到的是1-Wire上的最后一
79、個器件,則返回一個無效標記FALSE,并且把狀態(tài)設置成下一次調(diào)用搜索算法時將是‘FIRST’操作的狀態(tài)。</p><p> 以下例舉了三個器件的搜索過程,為便于說明,設器件的ROM碼只有2位。</p><p><b> 搜索實例 </b></p><p> (為了簡化本例中省去了家族碼值差異位的記錄和跟蹤)</p><
80、p><b> FIRST</b></p><p> LastDiscrepancy = LastDeviceFlag = 0</p><p> 執(zhí)行1-Wire復位操作并等待在線應答脈沖,若無在線應答脈沖則結(jié)束</p><p> id_bit_number = 1, last_zero = 0</p><p&g
81、t; 發(fā)送搜索命令, 0F0H</p><p> 讀第一個數(shù)據(jù)位id_bit: 1 (器件 A) AND 0 (器件 B) AND 1 (器件 C) = 0</p><p> 讀第一個數(shù)據(jù)位的補碼 cmp_id_bit: 0 (器件 A) AND 1 (器件 B) AND 0 (器件 C) = 0</p><p> 由于id_bit_number >
82、LastDiscrepancy,設置 search_direction = 0, last_zero = 1</p><p> 發(fā)送當前值為0的search_direction 數(shù)據(jù)位, 使器件A與器件C轉(zhuǎn)換到等待狀態(tài)</p><p> id_bit_number 值增到2</p><p> 讀第二個數(shù)據(jù)位id_bit: 0 (器件 B) = 0</p&
83、gt;<p> 讀第二個數(shù)據(jù)位的補碼cmp_id_bit: 1 (器件 B) = 1</p><p> 由于數(shù)據(jù)位與其補碼不同設置,search_direction = id_bit</p><p> 發(fā)送當前值為0的search_direction數(shù)據(jù)位,查找到器件B的ROM_NO值為‘00’、 并且是當前選擇</p><p>
84、 LastDiscrepancy = last_zero</p><p><b> NEXT</b></p><p> 1-Wire主機執(zhí)行復位操作并等待在線應答脈沖,若無在線應答脈沖則結(jié)束</p><p> id_bit_number = 1, last_zero = 0</p><p> 發(fā)送搜索命令,0F0
85、H</p><p> 讀第一個數(shù)據(jù)位id_bit: 1 (器件 A) AND 0 (器件 B) AND 1 (器件 C) = 0</p><p> 讀第一個數(shù)據(jù)位的補碼cmp_id_bit: 0 (器件 A) AND 1 (器件 B) AND 0 (器件 C) = 0</p><p> 由于id_bit_number = LastDiscrepancy,設置s
86、earch_direction = 1</p><p> 發(fā)送當前值為1的search_direction 數(shù)據(jù)位, 使器件B轉(zhuǎn)換到等待狀態(tài)</p><p> id_bit_number值增值到2</p><p> 讀第二個數(shù)據(jù)位id_bit: 0 (器件 A) AND 1 (器件 C) = 0</p><p> 讀第二個數(shù)據(jù)位的補碼
87、cmp_id_bit: 1 (器件 A) AND 0 (器件 C) = 0</p><p> 由于id_bit_number > LastDiscrepancy,設置search_direction = 0, last_zero = 2</p><p> 發(fā)送當前值為0的search_direction 數(shù)據(jù)位, 使器件C轉(zhuǎn)換到等待狀態(tài)</p><p>
88、 查找到器件A的ROM_NO 值為‘01’、并且是當前選擇</p><p> LastDiscrepancy = last_zero</p><p><b> NEXT</b></p><p> 執(zhí)行1-Wire復位操作并等待在線應答脈沖,若無在線應答脈沖則結(jié)束</p><p> id_bit_number =
89、1, last_zero = 0</p><p> 發(fā)送搜索命令,0F0H</p><p> 讀第一個數(shù)據(jù)位id_bit: 1 (器件 A) AND 0 (器件 B) AND 1 (器件 C) = 0</p><p> 讀第一個數(shù)據(jù)位的補碼cmp_id_bit: 0 (器件 A) AND 1 (器件 B) AND 0 (器件 C) = 0</p>
90、<p> 由于id_bit_number < LastDiscrepancy,設置search_direction = ROM_NO(第一位)= 1</p><p> 發(fā)送當前值為1 的search_direction 數(shù)據(jù)位, 使器件B轉(zhuǎn)換到等待狀態(tài)</p><p> id_bit_number值增值2</p><p> 讀第二個數(shù)據(jù)位i
91、d_bit: 0 (器件 A) AND 1 (器件 C) = 0</p><p> 讀第二個數(shù)據(jù)位的補碼cmp_id_bit: 1 (器件 A) AND 0 (器件 C) = 0</p><p> 由于id_bit_number = LastDiscrepancy,設置search_direction = 1</p><p> 發(fā)送當前值為1的search_d
92、irection 數(shù)據(jù)位,使器件A轉(zhuǎn)換到等待狀態(tài)</p><p> 查找到器件C的ROM_NO值為‘11’、并且是當前選擇</p><p> LastDiscrepancy = last_zero 值為0,所以設置 LastDeviceFlag = TRUE</p><p><b> NEXT</b></p><p&g
93、t; LastDeviceFlag值為TRUE,所以返回FALSE</p><p> LastDiscrepancy = LastDeviceFlag = 0</p><p><b> 高級變量搜索</b></p><p> 有3種利用同一組狀態(tài)變量LastDiscrepancy、LastFamilyDiscrepancy、LastDe
94、viceFlag、 ROM_NO實現(xiàn)的高級變化搜索可以得到三種高級變量搜索算法,這幾種高級搜索算法允許來指定作為搜索目標的器件的類型(家族碼)或者是指定需要跳過或驗證某類型的器件是否在線(參見表4)。</p><p><b> VERIFY</b></p><p> ‘VERIFY’ 操作用來檢驗已知ROM碼的器件是否連接在1-Wire總線上,通過提供ROM碼并對
95、</p><p> 該碼進行目標搜索就可確定此器件是否在線。首先將ROM_NO寄存器值設置為已知的ROM碼值,然后將LastDiscrepancy和LastDeviceFlag標志位分別設置為64(40H)和0;進行搜索操作,然后讀ROM_NO的輸出結(jié)果;如果搜索成功并且ROM_NO中存儲的仍是要搜索器件的ROM碼值,那么此器件就在1-Wire總線上。</p><p> TARGET
96、SETUP</p><p> ‘TARGET SETUP’操作就是用預置搜索狀態(tài)的方式首先查找一個特殊的家族類型,每個1-Wire器件都有一個字節(jié)的家族碼內(nèi)嵌在ROM碼中(參見圖1),主機可以通過家族碼來識別器件所具有的特性和功能。若1-Wire總線上有多片器件時,通常是將搜索目標首先定位在需注意的器件類型上,為了將一個特殊的家族作為搜索目標,需要將所希望的家族碼字節(jié)放到ROM_NO寄存器的第一個字節(jié)中,并且將
97、ROM_NO寄存器的復位狀態(tài)置零,然后將LastDiscrepancy設置為64(40H);把LastDeviceFlag和LastFamilyDiscrepancy設置為0。在執(zhí)行下一次搜索算法時就能找出所期望的產(chǎn)品類型的第一個器件;并將此值存入ROM_NO寄存器。需要注意的是如果1-Wire總線上沒有掛接所期望的產(chǎn)品類型的器件,就會找出另一類型的器件,所以每次搜索完成后,都要對ROM_NO寄存器中存儲的結(jié)果進行校驗。</p&g
98、t;<p> FAMILY SKIP SETUP</p><p> ‘FAMILY SKIP SETUP’操作用來設置搜索狀態(tài)以便跳過搜索到的指定家族中的所有器件,此操作只有在一個搜索過程結(jié)束后才能使用。通過把LastFamilyDiscrepancy復制到LastDiscrepancy,并清除LastDeviceFlag即可實現(xiàn)該操作;在下一搜索過程就會找到指定家族中的下一個器件。如果當前家族
99、碼分組是搜索過程中的最后一組,那么搜索過程結(jié)束并將LastDeviceFlag 置位。</p><p> 表4 搜索變量狀態(tài)的設置 </p><p><b> 結(jié)論</b></p><p> 本文提供的搜索算法可以找出任意給定的1-Wire器件組中獨一無二的ROM碼,這是保證多點1-Wire總線應用的關(guān)鍵,已知ROM碼后就可以對逐一選定
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 1-wire 搜索算法中英文翻譯資料
- 計算機畢業(yè)設計外文翻譯
- 淺析計算機聯(lián)鎖進路搜索算法
- 計算機專業(yè)畢業(yè)設計外文翻譯
- 計算機專業(yè)畢業(yè)設計-外文翻譯
- 計算機專業(yè)畢業(yè)設計外文翻譯27
- 計算機專業(yè)畢業(yè)設計外文翻譯--internet
- 計算機專業(yè)畢業(yè)外文翻譯1
- 計算機專業(yè)畢業(yè)設計外文資料翻譯3
- 計算機畢業(yè)設計外文翻譯----php訪問mysql
- 計算機專業(yè)畢業(yè)設計-外文翻譯--matlab 介紹
- 計算機畢業(yè)設計外文翻譯---數(shù)據(jù)倉庫
- 計算機外文翻譯1
- 計算機畢業(yè)設計---業(yè)務管理系統(tǒng)設計(含外文翻譯)
- 計算機專業(yè)畢業(yè)設計外文文獻翻譯部分
- 計算機專業(yè)畢業(yè)設計外文翻譯--jsp內(nèi)置對象
- 計算機專業(yè)畢業(yè)設計外文翻譯--數(shù)據(jù)庫
- 計算機畢業(yè)設計外文翻譯---sql server的簡介
- 計算機專業(yè)畢業(yè)設計(論文)外文翻譯2篇
- 計算機科學與技術(shù)畢業(yè)設計(論文)外文翻譯
評論
0/150
提交評論