中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機(jī)串口檢測程序(C語言代碼)

        51單片機(jī)串口檢測程序(C語言代碼)

        作者: 時間:2012-07-18 來源:網(wǎng)絡(luò) 收藏

        void send_char_com( unsigned char ch)
        {
        SBUF=ch;
        while (TI== 0 );
        TI= 0 ;
        }

        本文引用地址:http://www.antipu.com.cn/article/171154.htm

        //向發(fā)送一個字符串,strlen為該字符串長度
        void send_string_com( unsigned char *str, unsigned int strlen)
        {
        unsigned int k= 0 ;
        do
        {
        send_char_com(*(str + k));
        k++;
        } while (k strlen);
        }


        //接收中斷函數(shù)
        void serial () interrupt 4 using 3
        {
        if (RI)
        {
        unsigned char ch;
        RI = 0 ;
        ch=SBUF;
        if (ch> 127 )
        {
        count3= 0 ;
        inbuf1[count3]=ch;
        checksum= ch- 128 ;
        }
        else
        {
        count3++;
        inbuf1[count3]=ch;
        checksum ^= ch;
        if ( (count3==(INBUF_LEN- 1 )) (!checksum) )
        {
        read_flag= 1 ; //如果接收的數(shù)據(jù)達(dá)到INBUF_LEN個,且校驗沒錯,
        //就置位取數(shù)標(biāo)志
        }
        }
        }
        }


        main()
        {
        init_serialcomm(); //初始化串口
        while ( 1 )
        {
        if (read_flag) //如果取數(shù)標(biāo)志已置位,就將讀到的數(shù)從串口發(fā)出
        {
        read_flag= 0 ; //取數(shù)標(biāo)志清0
        send_string_com(inbuf1,INBUF_LEN);
        }
        }

        }


        上一頁 1 2 下一頁

        評論


        相關(guān)推薦

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

        關(guān)閉