在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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>

            新聞中心

            串口調(diào)試程序

            作者: 時間:2011-05-01 來源:網(wǎng)絡(luò) 收藏

            /*定義為中斷方式處理*/
            #define INTERSENDSTR
            /*不為8032系列芯片 */
            //#define CHIP_8032

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

            #i nclude absacc.h>
            #i nclude reg51.h>
            #i nclude string.h>
            #i nclude err.h


            #ifdef INTERSENDSTR
            unsigned char xdata sSendComBuf[256],sRecComBuf[256];
            unsigned char data bOut,bIn,bSout,bSin;
            #else
            #define DEFSENDCHAR TI=0;SBUF=ACC;while(!TI);TI=0;
            #endif
            //bps設(shè)置 9600就是 PSetBps(96)(11.0592Mhz)

            unsigned char PSetBps(unsigned int bps) SMALL
            {
            unsigned int t1;
            unsigned char t2;
            #ifdef INTERSENDSTR
            /*如果使用中斷方式發(fā)送數(shù)據(jù),必須等待發(fā)送數(shù)據(jù)完畢才能更換波特率 */
            while(bSin!=bSout)
            {
            ;
            }
            ES=0;
            #endif

            #ifdef CHIP_8032
            if(3456%bps)
            {
            return ERR_SET_BPS;
            }
            t1=3456/bps;
            t1--;t1=~t1;
            RCAP2H=t1/256;RCAP2L=t1;
            T2MOD=0x00;
            /*使用定時器2做波特率發(fā)生器 */
            T2CON=0x34;/*TF2=0;EXF2=0;RCLK=1;TCLK=1;EXEN2=0;TR2=1;C/T2=0;CP/RL2=0
            */
            #else
            t1=576/bps;
            if((576%bps)||((t1==0))||(t1>=2*256))
            {
            return ERR_SET_BPS;
            }
            if(t1>256)
            {
            PCON=00;
            t2=256-(288/bps);
            }
            else
            {
            PCON=0x80;
            t2=256-t1;
            }
            TH1=t2;TL1=t2;
            TR1=1;
            #endif
            /*模式3*/
            SM0=0;
            RI=0;TI=0;
            REN=1;
            SM1=1;
            SM2=1;
            #ifdef INTERSENDSTR
            bOut=bIn;
            bSout=bSin;
            ES=1;
            #endif
            return OK;
            }
            void PSendChar(unsigned char ch) SMALL
            {

            #ifdef INTERSENDSTR
            unsigned char tch;

            tch=bSin+1;
            while(tch==bSout)
            {
            ;
            }
            sSendComBuf[bSin]=ch;
            ES=0;
            if((bSout==bSin))
            {
            SBUF=sSendComBuf[bSin];
            bSin++;
            }
            else
            {
            bSin++;
            }
            ES=1;
            #else
            ACC=ch;
            DEFSENDCHAR;
            #endif
            }
            unsigned char PGetChar() SMALL
            {
            unsigned char ch;
            #ifdef INTERSENDSTR
            ch=sRecComBuf[bOut];
            bOut++;
            return ch;
            #else
            ch=SBUF;
            RI=0;
            #endif
            }
            bit PCharInCom() SMALL
            {
            #ifdef INTERSENDSTR
            if(bIn!=bOut)
            {
            return 1;
            }
            return 0;
            #else
            return RI;
            #endif
            }
            void PSendString(unsigned char *st) SMALL
            {
            while(*st)
            {
            PSendChar(*st);
            st++;
            }
            }
            void PSendArray(unsigned char *st,unsigned int len) SMALL
            {
            unsigned int ii;
            for(ii=0;iilen;ii++)
            {
            PSendChar(st[ii]);
            }
            }
            #ifdef INTERSENDSTR
            void PSerialInt() interrupt 4
            {
            if(RI)
            {
            sRecComBuf[bIn]=SBUF;
            bIn++;
            RI=0;
            }
            if(TI)
            {
            TI=0;
            if(bSout!=bSin)
            {
            bSout++;
            }
            if(bSout!=bSin)
            {
            SBUF=sSendComBuf[bSout];
            }
            }
            }
            #endif



            關(guān)鍵詞: 程序 調(diào)試 串口

            評論


            相關(guān)推薦

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

            關(guān)閉