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

<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)用 > 基于Proteus仿真的AVR單片機(jī)串口程序

        基于Proteus仿真的AVR單片機(jī)串口程序

        作者: 時間:2016-10-19 來源:網(wǎng)絡(luò) 收藏

          以前在上做過51的串口仿真沒有成功,昨天再次嘗試atmega16的串口仿真居然成功了;當(dāng)然仿真是最簡單的,實(shí)際做事的時候需要加上max232芯片,但仿真時就不需要了,

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

          程序功能:由串口助手向單片機(jī)發(fā)送一組數(shù)據(jù)“I LOVE YOU-----SBILY1988”,單片機(jī)收到數(shù)據(jù)后發(fā)送回串口助手,

          數(shù)據(jù)傳輸方向:計(jì)算機(jī)——>單片機(jī); 單片機(jī)——>計(jì)算機(jī);

          現(xiàn)送上仿真圖和程序:

          

         

          #include

          #include

          void init();

          void send(unsigned char);

          unsigned char receive();

          void main()

          {unsigned char i=0,a=300;

          init();

          while(1)

          {

          i=receive();

          send(i);

          }

          }

          void init() //初始化函數(shù)

          {

          UCSRB=BIT(4)|BIT(3); //使能發(fā)送和接收器

          UCSRC=BIT(7)|(3<<1); //設(shè)置數(shù)據(jù)幀格式(8數(shù)據(jù)位)

          UBRRH=0; //設(shè)置波特率為8MHZ晶振下 9600bps

          UBRRL=51;

          }

          void send(unsigned char data) //數(shù)據(jù)發(fā)送

          {

          while(!(UCSRA&BIT(5))); //等待發(fā)送緩沖器準(zhǔn)備完畢

          UDR=data;

          while(!(UCSRA&BIT(6))); //等待發(fā)送結(jié)束

          UCSRA&=BIT(6);

          }

          unsigned char receive() //數(shù)據(jù)接收

          {unsigned char data=0;

          while(!(UCSRA&BIT(7))); //等待數(shù)據(jù)接收完畢

          data=UDR;

          return data;

          }



        關(guān)鍵詞: Proteus AVR

        評論


        相關(guān)推薦

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

        關(guān)閉