DS18B20中文资料 - 图文 

loading 分享 2026-8-15 下载文档

6/789// DELAY - with an 11.059MHz crystal// Calling the routine takes about 24μs, and then// each count takes another 16μs//void delay (int μs){int s;for (s = 0; s < μs; s++);}void write_bit(char bitval){DQ = 0;// pull DQ low to start timeslotif(bitval==1) DQ =1; // return DQ high if write 1delay(5);// hold value for remainder of timeslotDQ = 1;}// Delay provides 16μs per loop, plus 24μs Therefore, delay(5) = 104μs7. 4. unsigned char ow_reset(void){ unsigned char presence; DQ = 0;//pull DQ line lowdelay(29);// leave it low for 480μsDQ = 1; // allow line to return highdelay(3); // wait for presencepresence = DQ;// get presence signaldelay(25);// wait for end of timeslot return(presence);// presence signal returned} // presence = 0, no part = 1unsigned char read_byte(void){unsigned char i;unsigned char value = 0;for (i = 0; i < 8; i++){if(read_bit()) value| = 0 x 01<>i; // shifts val right ‘i’ spacestemp &= 0x01; // copy that bit to tempwrite_bit(temp); // write bit in temp into}delay(5)}6. 9. 17


DS18B20中文资料 - 图文 .doc 将本文的Word文档下载到电脑
搜索更多关于: DS18B20中文资料 - 图文  的文档
相关推荐
相关阅读