DS18B20温度传感器64位ROM地址读取(STC89C52)
程序代码:
#include
#define
#define
sbit
sbit
sbit
sbit
uchar
uchar
uchar
int
float
uchar
//*****************LCD1602*******************************
void
{
uint
for(x
for(y
}
void
{
lcdrs
P0
delay(5);
lcden
delay(5);
lcden
}
void
{
lcdrs
P0
delay(5);
lcden
delay(5);
lcden
}
void
{
uchar
lcdrw
lcden
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
for(i
{
write_date(table[i]);
delay(5);
}
write_com(0x80+0x40);
for(i
{
write_date(table1[i]);
delay(5);
}
write_com(0x80+11);
write_date(0xdf);
write_com(0x80+0x40+11);
write_date(0xdf);
}
//*******************DS18B20****************************
void
{
uint
ds
i
while(i>0)
i--;
ds
i
while(i>0)
i--;
}
bit
{
uint
bit
ds
i++;
ds
i++;
i++;
dat
i
while(i>0)
i--;
return
}
uchar
{
uchar
dat
for(i
{
j
dat
}
return
}
void
{
uint
uchar
bit
for(j
{
testb
dat
if(testb)//写1
{
ds
i++;i++;
ds
i
while(i>0)
i--;
}
else
{
ds
i
while(i>0)
i--;
ds
i++;i++;
}
}
}
void
{
dsreset();
delay(1);
tempwrite(0x44);
}
uint
{
uchar
dsreset();
delay(1);
tempwrite(0xcc);
tempwrite(0xbe);
a
b
temp
temp<=8;
temp
if(temp<0x0fff)
temp=~temp+1;
tflag=1;//负值标识符
f_temp
temp
//f_temp
return
}
void
{
write_com(address);
write_date(date);
}
void
{
uint
w1
w2
w3
w4
if(tflag==0)
write_wendu(0x80+5,0x20);
else
write_wendu(0x80+5,0x2d);
if(w1==0)
{
write_wendu(0x80+6,0x20);//百位为0,不显示
if((w1==0)&&(w2==0))
write_wendu(0x80+7,0x20);
else
write_wendu(0x80+7,0x30+w2);
write_wendu(0x80+8,0x30+w3);
}
else
{
write_wendu(0x80+6,0x30+w1);
write_wendu(0x80+10,0x30+w4);
}
}
void
{
uint
dsreset();
delay(1);
{
fCode[i]=tempread();
}
write_com(0x80+0x40);
for
{
xulie
xulie
}
}
//************************************************
void
{
DispCode();
while(1)
{//searchrom();
tempchange();
display();
}
}
DS18B20温度传感器地址读取STC89C5 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)