<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機串口通信源碼

          單片機串口通信源碼

          作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          本測試程序選擇STC12C4052AD單片機,采用內(nèi)部晶振6M起振,傳輸波特率為2400bps,測試于2012年11月17日通過。使用STC-ISP,V488版本刷機,用其自帶串口助手程序測試。源代碼如下:
          #include #include unsigned char tmp;void send_int(void);void send_char(unsigned char txd);main(){send_int();while(1){if(RI)      // 是否有數(shù)據(jù)到來{tmp = SBUF;                   // 暫存接收到的數(shù)據(jù)     send_char(tmp);     //數(shù)據(jù)傳回RI = 0;                       //RI清零}}}void send_int(void){ TMOD =0x20;//T1工作為方式2SCON =0x50;//方式1:10位異步同通訊,串口允許接收PCON =0x80;//波特率倍增,SMOD=1TH1=TL1=0xf3;  // 波特率2400TR1=1;// 啟動定時器1ES=1;EA=1;//總中斷允許}void send_char(unsigned char txd)// 傳送一個字符{SBUF = txd;while(!TI);TI=0;}void send_string(char *s)//傳送字符串時使用{while(*s){send_char(*s++);}}


          關(guān)鍵詞: 單片機串口通

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁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); })();