⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 futions.h

📁 主从式总线型SIO系统(多机双向通信)
💻 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)	//串口设置
{
	
	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;
	
}
/*************************************************************
**功能:温度处理函数											**
**参数:无返回												**
*************************************************************/
void temperature_process(uchar low,uchar high)
{
	int temp1,temp2,temp3;
	if(high&0x80)//判断正负
	{
	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);
	
	}
}
/*************************************************************
**功能:温度数值处理函数											**
**参数:无返回												**
*************************************************************/
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;
}
/****************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -