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

<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è)計(jì)應(yīng)用 > 串行通信UART和PROTEUS仿真設(shè)計(jì)

        串行通信UART和PROTEUS仿真設(shè)計(jì)

        作者: 時(shí)間:2012-01-10 來源:網(wǎng)絡(luò) 收藏

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

        atmega64的程序:

        兩個(gè)文件,一個(gè)是將函數(shù)模塊化,別一個(gè)是主函數(shù),調(diào)用(- -!最近習(xí)慣將程序模塊化。。。)

        //------------------uart.c---------------------

        //----這里將函數(shù)模塊化------------

        #include iom64v.h>

        void uart0_init(void)
        {
        UCSR0B = 0x00; //disable while setting baud rate
        UCSR0A = 0x00;
        UCSR0C = 0x06;
        UBRR0L = 0x33; //set baud rate lo
        UBRR0H = 0x00; //set baud rate hi
        UCSR0B = 0x18;
        }


        void uart0_Transmit( unsigned char da
        ta )
        {
        /* Wait for empty transmit buffer */
        while ( !( UCSR0A (1UDRE0)) )
        ;
        /* Copy ninth bit to TXB8 */
        UCSR0B = ~(1TXB80);
        //if ( da
        ta 0x0100 )
        //UCSR0B |= (1TXB80);
        /* Put da
        ta into buffer, sends the data */
        UDR0 = da
        ta;
        }

        unsigned char uart0_Receive( void )
        {
        /* 等待接收數(shù)據(jù)*/
        while ( !(UCSR0A (1RXC0)) )
        ;
        /* 從緩沖器中獲取并返回?cái)?shù)據(jù)*/
        return UDR0;
        }

        //--------------main.c-----------

        //--------------------------------

        #include iom64v.h>
        #include spi.h
        #define commun_symbol 0x31

        //-----------send a commun_symbol-----
        //-----------receive a commun_symbol--
        // --no,continue receive||||||yes-->receive the da
        ta and send
        void main()
        {
        unsigned char bybuff;
        DDRB=0xff;
        PORTB=0xff;
        uart0_init();
        {

        do
        {
        bybuff=uart0_Receive();
        }
        while (bybuff!=commun_symbol);//commun_symbol);
        while(1)
        {

        uart0_Transmit(bybuff);
        bybuff=uart0_Receive();
        PORTB=(0xff|bybuff);
        }
        }
        }

        ok,任務(wù)完成了,改天實(shí)驗(yàn)一下!


        上一頁 1 2 下一頁

        評論


        相關(guān)推薦

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

        關(guān)閉