|
把時間 初始化函數(shù) 和 讀時間函數(shù) 注釋掉,才可正常顯示溫度
我全部取消掉注釋的話,時間時可以正常走,但是溫度顯示為00.0°C
下面時相對應(yīng)的一些函數(shù)
void Ds1302Init() //時間初始化
{
uchar n;
Ds1302Write(0x8E,0x00); //關(guān)閉寫保護(hù)功
for (n=0; n<7; n++)//寫入7個字節(jié)的時鐘信號:分秒時日月周年
{
Ds1302Write(WRITE_RTC_ADDR[n],TIME[n]);
}
Ds1302Write(0x8E,0x80); //打開寫保護(hù)
}
void Ds1302ReadTime() //讀時間
{
uchar n;
for (n=0; n<7; n++)//讀取7個字節(jié)的時鐘信號:分秒時日月周年
{
TIME[n] = Ds1302Read(READ_RTC_ADDR[n]);
}
}
void get_temp()
{
init_temp();
write_temp(0xcc); //跳過ROM
write_temp(0x44); //溫度轉(zhuǎn)換
delay1(1000); //等待轉(zhuǎn)換1000毫秒
init_temp();
write_temp(0xcc); //跳過ROM
write_temp(0xbe); //讀RAM內(nèi)容
low=read_temp(); //低8位
high=read_temp(); //高8位
temp=high;
temp<<=8;
temp=temp|low; //合并
temp=temp*10*0.0625+0.5; //轉(zhuǎn)換
s[0]=temp/100; //十位
s[1]=temp%100/10; //個位
s[2]=temp%10; //小數(shù)
}

|
|