DS18B20匹配ROM地址单总线多点测温(STC89C52)
程序代码:
#include
#define
#define
sbit
sbit
sbit
sbit
uchar
uchar
//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(table1[i]);
delay(5);
}
write_com(0x80+0x41);
for(i
{
write_date(0x2d);
delay(100);
}
write_com(0x80);
for(i
{
write_date(table[i]);
delay(5);
}
write_com(0x80+0x40);
for(i
{
write_date(table[i]);
delay(5);
}
}
//*******************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
{
char
tempwrite(0x55);
if(a==1)
{
for(j=0;j<8;j++)
tempwrite(rom1[j]);//发送18B20的序列号,先发送低字节
}
if(a==2)
{
for(j=0;j<8;j++)
tempwrite(rom2[j]);//发送18B20的序列号,先发送低字节
}
}
uint
{
uchar
dsreset();
delay(1);
//tempwrite(0xcc);
//dsreset();
if(z==1)
matchrom(1);
if(z==2)
matchrom(2);
tempwrite(0x44);
delay(5);
dsreset();
delay(1);
//tempwrite(0xcc);
//tempwrite(0xcc);
//dsreset();
if(z==1)
matchrom(1);
if(z==2)
matchrom(2);
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
{
write_wendu(0x80,N);
write_wendu(0x81,O);
write_wendu(0x82,.);
write_wendu(0x84,:);
write_wendu(0x89,.);
write_wendu(0x8b,0xdf);
write_wendu(0x8c,C);
write_wendu(0x80+0x40,N);
write_wendu(0x81+0x40,O);
write_wendu(0x82+0x40,.);
write_wendu(0x84+0x40,:);
write_wendu(0x89+0x40,.);
write_wendu(0x8b+0x40,0xdf);
write_wendu(0x8c+0x40,C);
}
void
{
uint
w1
w2
w3
w4
if(z==1)
{
}
if(z==2)
{
addr=0x40;
write_com(0x80+0x40+3);
write_date(0x30+2);
}
if(tflag=
DS18B20ROM地址多点测温STC89C5 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)