msp430單片機(jī)的ds18b20測(cè)溫度c程序
#define DS18B20_DIR
#define DS18B20_IN
#define DS18B20_OUT
#define DS18B20_DQ
#define DS18B20_DQ_2
// DS18B20 ROM命令宏定義
#define ReadRom
#define MatchRom
#define SearchRom
#define AlertSearch
#define CopyScratchpad
#define SkipRom
#define ReadPower
// DS18B20 功能命令宏定義
#define ConvertTemperature
#define ReadScratchpad
#define WriteScratchpad
#define RecallE
#define SMCLK
// 溫度的十進(jìn)制編碼(查表用)
unsigned char decimalH[16]={00,06,12,18,25,31,37,43,50,56,62,68,75,81,87,93};
unsigned char decimalL[16]={00,25,50,75,00,25,50,75,00,25,50,75,00,25,50,75};
// 變量定義
unsigned char GetScratchpad[9];
unsigned char GetScratchpad_2[9];
float ResultTemperatureH;
float ResultTemperatureLH;
float ResultTemperatureLL;
float ResultTemperatureH_2;
float ResultTemperatureLH_2;
float ResultTemperatureLL_2;
float ResultTemperature;
float ResultTemperature_2;
float Temperaturefromtwo;
float OilPercentage;
void DS18B20_WriteBit(unsigned char oww_dat);
void DS18B20_WriteBit_2(unsigned char oww_dat);
void DS18B20_WriteByte(unsigned char oww_dat);
void DS18B20_WriteByte_2(unsigned char oww_dat);
void DS18B20_ReadTemp(void);
void DS18B20_ReadTemp_2(void);
unsigned char DS18B20_Init(void);
unsigned char DS18B20_Init_2(void);
unsigned char DS18B20_ReadBit(void);
unsigned char DS18B20_ReadBit_2(void);
unsigned char DS18B20_ReadByte(void);
unsigned char DS18B20_ReadByte_2(void);
void Delay10us(void);
void DelayX10us(unsigned char x10us);
void main(void) {
}
評(píng)論