在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 模擬串口的實(shí)現(xiàn)單片機(jī)IO口

            模擬串口的實(shí)現(xiàn)單片機(jī)IO口

            作者: 時(shí)間:2016-11-19 來(lái)源:網(wǎng)絡(luò) 收藏
            用EBOX向我們的電力線調(diào)試模塊發(fā)數(shù)據(jù),但是要有一個(gè)控制接口,但是EBOX沒(méi)有提供,所有只好用MCU來(lái)做伺服器。

            一般的單片機(jī)都只有一個(gè)串口,所以必須模擬一個(gè)出來(lái)。

            本文引用地址:http://www.biyoush.com/article/201611/318339.htm

            /*

            sbit TXD1= P1^4;//define p14 as the analog transmit port

            sbit RXD1= P1^2;//define p12 as the analog recieve port

            */

            #include "REG52.H"

            #define uint unsigned int

            #define uchar unsigned char

            #include

            void WaitTF0(void);

            void TIMEINI(void)//counter initial

            {

            TMOD=0x02;

            TH0=0xA0;、//9600 BPS

            TL0=TH0;

            TR0=1;

            TF0=0;

            }

            void WByte(uchar input)//send function

            {

            uchar i=8;

            TR0=1;

            TXD1=0;//begin bit

            WaitTF0();

            //send the Byte

            while(i--)

            {

            TXD1=input&0x01;//send Byte from low bit to high bit

            WaitTF0();

            input=input>>1;//right shift

            }

            TXD1=1;//stop bit

            WaitTF0();

            TR0=0;//stop the counter

            }

            uchar RByte()//the recieve function

            {

            uchar Output=0;

            uchar i=8;

            while(RXD1);

            i=i;

            i=i;

            i=i;

            i=i;

            i=i;

            i=i;

            i=i;

            TR0=1;//計(jì)數(shù)器開(kāi)始工作

            WaitTF0();

            while(i--)//接收8位數(shù)據(jù)位

            {

            Output>>=1;

            if(RXD1)Output=Output|0x80;//recieve from the high bit to low bit

            WaitTF0();

            }

            TR0=0;

            returnOutput;

            }

            void WaitTF0(void)//check the counter

            {

            while(!TF0);

            TF0=0;

            }



            關(guān)鍵詞: 模擬串口單片機(jī)IO

            評(píng)論


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

            關(guān)閉