51單片機串口通信中字符發(fā)送的總結(jié)
/*字符發(fā)送方式一*/
#includereg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar flag,a,i;
uchar code table[]="I get ";
void init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SM0=0;
SM1=1;
REN=1;
//TI=1;
EA=1;
ES=1;
}
void main()
{
init();
while(1)
{
if(flag==1)
{
ES=0;
for(i=0;i6;i++)
{
SBUF=table[i];
while(TI==0);
TI=0;
}
SBUF=a;
while(TI==0);
TI=0;
ES=1;
flag=0;
}
}
}
void ser() interrupt 4
{
a=SBUF;
RI=0;
P1=~P1;
flag=1;
}
/*字符發(fā)送方式二*/
#includereg52.h>
#includestdio.h>
#includeintrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar flag,a,i=0;
uchar code table[]="I get ";
void init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SM0=0;
SM1=1;
REN=1;
//TI=1;
EA=1;
ES=1;
}
void main()
{
init();
while(1)
{
if(flag==1)
{
ES=0;
while(table[i]!='看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();