51控制兩個或者多個DS18b20時,用一個IO口怎么控制,之前有查過要匹配ROM,可是搞了好久都沒成功,哪位大佬解答一下。。。
uj5u.com熱心網友回復:
先單個18B20作業,分別寫入地址后,再串接一起,就可以根據設定的地址給控制uj5u.com熱心網友回復:
可以說清楚點嗎?分別寫入地址?不用匹配ROM嗎?
uj5u.com熱心網友回復:
不好意思,我記錯了,是先單個器件的時候,讀出ID碼,然后使用iD碼識別每個器件64-BIT LASERED ROM CODE
Each DS18B20 contains a unique 64 – bit code (see Figure 6) stored in ROM. The least significant 8 bits
of the ROM code contain the DS18B20’s 1- Wire family code: 28h. The next 48 bits contain a unique
serial number. The most significant 8 bits contain a cyclic redundancy check (CRC) byte that is
calculated from the first 56 bits of the ROM code. A detailed explanation of the CRC bits is provided in
the CRC Generation section. The 64- bit ROM code and associated ROM function control logic allow the
DS18B20 to operate as a 1- Wire device using the protocol detailed in the 1- Wire Bus System section .
uj5u.com熱心網友回復:
DS18B20_WriteByte(ch, 0x55);DS18B20_WriteByte(ch, sn[0]);
DS18B20_WriteByte(ch, sn[1]);
DS18B20_WriteByte(ch, sn[2]);
DS18B20_WriteByte(ch, sn[3]);
DS18B20_WriteByte(ch, sn[4]);
DS18B20_WriteByte(ch, sn[5]);
DS18B20_WriteByte(ch, sn[6]);
DS18B20_WriteByte(ch, sn[7]);
DS18B20_WriteByte(ch, 0xBE);
具體看手冊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/64351.html
標籤:單片機/工控
上一篇:W5500模塊相關問題
