欢迎来到天天文库
浏览记录
ID:38662311
大小:49.50 KB
页数:4页
时间:2019-06-17
《多路温度采集系统程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、主机程序#includesbitRS=P2^5;sbitRW=P2^6;sbitEN=P2^7;sbitE=P2^3;voidmaster(void);unsignedcharcort=0;unsignedchartable1[]="111111";unsignedchartable2[]="111111";unsignedchartable3[]="111111";unsignedchartable4[]="111111";unsignedcharnum=0;Delay(unsignedinti){while(i--);}voiddelay_50us(unsign
2、edintt){unsignedintj;for(;t>0;t--)for(j=19;j>0;j--);}voidwrite_com(unsignedcharcom){EN=0;RS=0;RW=0;P1=com;delay_50us(10);EN=1;delay_50us(20);EN=0;}voidwrite_data(unsignedchardat){EN=0;RS=1;RW=0;P1=dat;delay_50us(10);EN=1;delay_50us(20);EN=0;}voidinit_1602(void){delay_50us(300);write_com(0x38);d
3、elay_50us(100);write_com(0x38);delay_50us(100);write_com(0x38);write_com(0x08);write_com(0x01);write_com(0x06);write_com(0x0c);}voidmain(){unsignedcharj;unsignedchari;unsignedchark;unsignedchart;TMOD=0x20;TH1=0xcc;//波特率600TL1=0xcc;TR1=1;SCON=0xf8;EA=1;PCON=0x00;EX0=1;//外部中断0允许IT0=1;//外部中断0下降沿触发
4、E=1;init_1602();delay_50us(2);while(1){//从机一//write_com(0x81);for(j=0;j<6;j++){write_data(table2[j]);}Delay(200);if(cort==1){SBUF=0X01;while(TI!=1);TI=0;E=0;SM2=0;Delay(2000);for(num=0;num<6;num++){while(RI!=1);RI=0;table2[num]=SBUF;}SM2=1;E=1;}//从机二//write_com(0x80+0X41);for(i=0;i<6;i++){write
5、_data(table1[i]);}Delay(2000);if(cort==2){SBUF=0X02;while(TI!=1);TI=0;E=0;SM2=0;Delay(200);for(num=0;num<6;num++){while(RI!=1);RI=0;table1[num]=SBUF;}SM2=1;E=1;}//从机三//write_com(0x89);for(k=0;k<6;k++){write_data(table3[k]);}Delay(2000);if(cort==3){SBUF=0X03;while(TI!=1);TI=0;E=0;SM2=0;Delay(200
6、);for(num=0;num<6;num++){while(RI!=1);RI=0;table3[num]=SBUF;}SM2=1;E=1;}//从机四//write_com(0x80+0x49);for(t=0;t<6;t++){write_data(table4[t]);}Delay(2000);if(cort==4){SBUF=0X04;while(TI!=1);TI=0;E=0;SM2=0;Delay(200);for(num=0;num<6;num++){while(RI!=1);RI=0;table4[num]=SBUF;}SM2=1;E=1;cort=0;}}}key
7、_serial()interrupt0using1{++cort;}从机程序#include#defineucharunsignedchar#defineuintunsignedintunsignedcharsend_tem1[]="00.0^C";unsignedcharnum=0;sbitDQ=P3^3;sbitE=P2^3;voiddelay(unsignedintaa){while(aa--);}voidds1820rst(){u
此文档下载收益归作者所有