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

          新聞中心

          STC8954RD 串口接收

          作者: 時間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
          #include
          #include
          #include
          #include
          #include
          //初始化串口
          void InitCOM(void)
          {
          #if 1
          SCON = 0x50; //8bit
          TMOD = 0x20; //timer1 mode 2
          PCON = 0x00; //SMOD=1, double baud
          TL1 = 0xFD;
          TH1 = 0xFD; //Baud = 9600, 11.0592MHz
          //IE |= 0x90; //Serail break enable
          TR1 = 1; //timer1 start
          ES = 0;
          EA = 0; //disable interrupt
          #else
          SCON = = 0x50;
          TH2 = 0XFF;
          TL2 = 0xFD //baud = 115200, 11.0592MHz
          RCAP2H = 0xFF;
          RCAP2L = 0xFD; //
          TCLK = 1;
          RCLK = 1;
          C-T2 = 0;
          TR2 = 1;
          #endif
          }
          //寫串口
          void COMPutc(char cdata)
          {
          SBUF = cdata;
          while(!TI);
          TI = 0;
          }
          void COMWrite(char* str)
          {
          while(*str)
          COMPutc(*str++);
          }
          void COMWriteNum(int num, char* str)
          {
          char d[32];
          sprintf(d, "%s:%dn", str, num);
          COMWrite(d);
          }
          //讀取串口
          char COMGetc(void)
          {
          char temp;
          while(!RI);
          temp = SBUF;
          RI = 0;
          return temp;
          }
          void COMRead(char* str, unsigned char length)
          {
          unsigned char i = 0;
          for(i = 0; i < length; i++)
          {
          str[i] = COMGetc();
          }
          }
          void COMReadEnter(char* str)
          {
          char temp;
          do
          {
          //Delay(1);
          //COMWrite("ndatan");
          temp = COMGetc();
          *str=temp;
          //COMPutc(temp);
          str++;
          }while(temp!=n && temp!=r);
          *str = 看屁屁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); })();