?? futions.h
字號:
#define uchar unsigned char
#define uint unsigned int
char volatile xiaoshu_temp[5],zhen_temp[4];
bit dot_dis=1;
bit flag;
char TTemp=0;
char TTemp1=0;
char volatile DS18B20_Data[4];
void process(unsigned char,unsigned char);
void Serial_Set(void) //串口設(shè)置
{
SCON=0x50;
TMOD=TMOD&0x0f;
TMOD=TMOD|0x20;
TH1 = 0xf3; // 6MHZ 波特率2400
TL1 = 0xf3;
//TH1=0xfd;
//TL1=0xfd;
TR1=1;
TI=1; //用PRINTF時,TI要置1
}
void Serial_Init(void) //串口初始化
{
SCON = 0x50; //SCON=0xd8;
TMOD=0x20;
PCON =0x80; // 波特率倍增 SMOD=1
TH1 = 0xf3; // 6MHZ 波特率2400
TL1 = 0xf3;
//TH1=0xfd;
//TL0=0xfd;
TR1=1;
ES=1;
}
void Interrupt_Init(void) //中斷初始化
{
EA=1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
}
/*************************************************************
**功能:溫度處理函數(shù) **
**參數(shù):無返回 **
*************************************************************/
void temperature_process(uchar low,uchar high)
{
int temp1,temp2,temp3;
if(high&0x80)//判斷正負(fù)
{
flag=1;
temp3=temp3|high;
temp3=temp3&0x00ff;
temp3=temp3<<8;
temp1=temp3;
temp1=temp1|low;
temp1=(temp1^0xffff);
temp1=temp1+1; //取反加1
low=temp1&0x000f;
high=temp1>>4;
process(high,low);
}
else
{
flag=0; //zhen
temp1=high;
temp2=low;
temp1=temp1<<4;
temp2=temp2>>4;
temp3=temp1|temp2;
high=temp3;
low=low&0x0f;
process(high,low);
}
}
/*************************************************************
**功能:溫度數(shù)值處理函數(shù) **
**參數(shù):無返回 **
*************************************************************/
void process(unsigned char high,unsigned char low)
{
uint temp1;
uchar i;
temp1=low*625;
xiaoshu_temp[0]=temp1/1000+'0';
xiaoshu_temp[1]=temp1/100%10+'0';
xiaoshu_temp[2]=temp1%100/10+'0';
xiaoshu_temp[3]=temp1%10+'0';
xiaoshu_temp[4]='\0';
if(xiaoshu_temp[3]=='0')
{
xiaoshu_temp[3]='\0';
if(xiaoshu_temp[2]=='0')
{
xiaoshu_temp[2]='\0';
if(xiaoshu_temp[1]=='0')
{
xiaoshu_temp[1]='\0';
if(xiaoshu_temp[0]=='0')
{
xiaoshu_temp[0]='\0';
dot_dis=0;
}
}
}
}
zhen_temp[0]=high/100+'0';
zhen_temp[1]=high%100/10+'0';
zhen_temp[2]=high%10+'0';
zhen_temp[3]='\0';
for(i=0;i<2;i++)
if(zhen_temp[0]=='0')
{zhen_temp[0]=zhen_temp[1];
zhen_temp[1]=zhen_temp[2];
zhen_temp[2]='\0';
}
else
break;
}
/****************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -