初级会员

- 积分
- 54
- 金钱
- 54
- 注册时间
- 2019-3-2
- 在线时间
- 11 小时
|
1金钱
DS18B20的读写为什么不能通过寄存器寻址然后读写呢?向DS18B20写的数据是自动存储在那个高速暂存RAM里面吗?最后是
short DS18B20_Get_Temp(void)
{
u8 temp;
u8 TL,TH;
short tem;
DS18B20_Start (); // ds1820 start convert
DS18B20_Rst();
DS18B20_Check();
DS18B20_Write_Byte(0xcc);// skip rom
DS18B20_Write_Byte(0xbe);// convert
TL=DS18B20_Read_Byte(); // LSB
TH=DS18B20_Read_Byte(); // MSB
if(TH>7)
{
TH=~TH;
TL=~TL;
temp=0;//ζèÎa¸o
}else temp=1;//ζèÎaÕy
tem=TH; //»ñμø߰Ëλ
tem<<=8;
tem+=TL;//»ñμÃμ×°Ëλ
tem=(double)tem*0.625;//×a»»
if(temp)return tem; //·μ»ØÎ¶èÖμ
else return -tem;
}
DS18B20_Write_Byte(0xcc);// skip rom
DS18B20_Write_Byte(0xbe);// convert
这两个函数在这里是起什么作用的呢?如果没有会怎么样?
求老哥解答。
|
|