欢迎来到天天文库
浏览记录
ID:61462140
大小:70.50 KB
页数:31页
时间:2021-02-02
《C语言补充附录.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、[基本练习]中的C语言程序对照[基本练习4-1]#includesbitP10=P1^0;voidSQ500(){TMOD=0x01;TL0=0x0C;TH0=0xFE;TR0=1;while(1){while(TF0==0);TF0=0;TL0=0x0C;TH0=0xFE;P10=~P10;}}[基本练习4-2]#includesbitP33=P3^3;voidSTW(){unsignedchardataHi,Low;TMOD=0x90;TL1=0x00;TH1=0x00;P33=1
2、;while(P33==1);TR1=1;while(P33==0);while(P33==1);TR1=0;Hi=TH1;Low=TL1;}[基本练习4-3]#includesbitP35=P3^5;voidMSFC(){unsignedchari;unsignedchardataHi,Low;TMOD=0x51;TL1=0x00;TH1=0x00;TL0=0xB0;TH0=0x3C;P35=1;while(P35==1);TR0=1;TR1=1;for(i=0;i<0x0A;i++){while(T
3、F0==0);TF0=0;TL0=0xB0;TH0=0x3C;}TR1=0;TR0=0;Hi=TH1;Low=TL1;}[基本练习4-4]#includesbitP10=P1^0;voidSQSU()interrupt1using2{P10=~P10;TL0=0x0C;TH0=0xFE;}voidmain(){TMOD=0x01;TL0=0x0C;TH0=0xFE;EA=1;ET0=1;TR0=1;while(1);}[基本练习4-5]#includesbitP35=P3^5;unsi
4、gnedchardatai,j,Hi,Low;voidMSUI()interrupt1using2{j--;if(j==0){TR1=0;TR0=0;Low=TL1;Hi=TH1;i=1;}else{TL0=0x0B;TH0=0x3C;}}voidMSFI(){TMOD=0x51;j=0x0A;TL1=0x00;TH1=0x00;TL0=0x0B;TH0=0x3C;P35=1;while(P35==1);TR0=1;TR1=1;EA=1;ET0=1;i=0;while(i==0);}[基本练习4-6]#include5、EG51.H>sbitP33=P3^3;unsignedchardataHi,Low;voidMSTI()interrupt2using3{if(TH1!=TL16、7、TL1!=0x00){TR1=0;F0=1;Hi=TH1;Low=TL1;}else{TR1=1;}}voidMSTFM(){IT1=1;TL1=0x00;TH1=0x00;TMOD=0x10;F0=0;P33=1;while(P33==1);EA=1;EX1=1;while(F0==0);}[基本练习4-7]#includeunsigne8、dchardatasbufdata[16];voidTXD1(){unsignedchari;TMOD=0x20;TL1=0xE8;TH1=0xE8;ET1=0;TR1=1;SCON=0x40;PCON=0x00;for(i=0;i<0x10;i++){SBUF=sbufdata[i];while(TI==0);TI=0;}}[基本练习4-8]#includeunsignedchardatasbufdata[16];voidRXD2(){unsignedchari;SCON=0x80;PCON=0x809、;for(i=0;i<0x10;i++){REN=1;while(RI==0);RI=0;sbufdata[i]=SBUF;}}[基本练习4-9]#includeunsignedchardatasbufdata[16];voidTXDP(){unsignedchari;TMOD=0x20;TL1=0xE8;TH1=0xE8;ET1=0;TR1=1;SCON=0xC0;PCON=0x00;for(i=0;i<0x10;i++){ACC=sbufdata[i];TB8=P;SBUF=sbufdata[i];10、while(TI==0);TI=0;}}[基本练习4-10]#includeunsignedchardatasbufdata[16];voidRXDP(){unsignedchari;SCON=0x80;PCON=0x80;for(i=0;i<0x10;i++){REN=1;while(RI==0)
5、EG51.H>sbitP33=P3^3;unsignedchardataHi,Low;voidMSTI()interrupt2using3{if(TH1!=TL1
6、
7、TL1!=0x00){TR1=0;F0=1;Hi=TH1;Low=TL1;}else{TR1=1;}}voidMSTFM(){IT1=1;TL1=0x00;TH1=0x00;TMOD=0x10;F0=0;P33=1;while(P33==1);EA=1;EX1=1;while(F0==0);}[基本练习4-7]#includeunsigne
8、dchardatasbufdata[16];voidTXD1(){unsignedchari;TMOD=0x20;TL1=0xE8;TH1=0xE8;ET1=0;TR1=1;SCON=0x40;PCON=0x00;for(i=0;i<0x10;i++){SBUF=sbufdata[i];while(TI==0);TI=0;}}[基本练习4-8]#includeunsignedchardatasbufdata[16];voidRXD2(){unsignedchari;SCON=0x80;PCON=0x80
9、;for(i=0;i<0x10;i++){REN=1;while(RI==0);RI=0;sbufdata[i]=SBUF;}}[基本练习4-9]#includeunsignedchardatasbufdata[16];voidTXDP(){unsignedchari;TMOD=0x20;TL1=0xE8;TH1=0xE8;ET1=0;TR1=1;SCON=0xC0;PCON=0x00;for(i=0;i<0x10;i++){ACC=sbufdata[i];TB8=P;SBUF=sbufdata[i];
10、while(TI==0);TI=0;}}[基本练习4-10]#includeunsignedchardatasbufdata[16];voidRXDP(){unsignedchari;SCON=0x80;PCON=0x80;for(i=0;i<0x10;i++){REN=1;while(RI==0)
此文档下载收益归作者所有