好文档 - 专业文书写作范文服务资料分享网站

DS18B20中文资料 - 图文 

天下 分享 时间: 加入收藏 我要投稿 点赞

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中文资料 - 图文 

6/789//DELAY-withan11.059MHzcrystal//Callingtheroutinetakesabout24μs,andthen//eachcounttakesanother16μs//voiddelay(intμs){ints;for(s=0;s<μs;s++);}voidwrite_bit(char
推荐度:
点击下载文档文档为doc格式
1rqum101e92nsft0jg51
领取福利

微信扫码领取福利

微信扫码分享