<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 51單片機串口通信仿真實現16 16點陣顯示程序

          51單片機串口通信仿真實現16 16點陣顯示程序

          作者: 時間:2016-11-23 來源:網絡 收藏
          首先要了解串口通信的基本工作原理,連接圖如下:







          虛擬終端連接:
          單片機+虛擬終端(作為串口輸入設備)+串口

          連接圖如下:



          設置如下:




          單片機虛擬終端選項作用如下:


          如果輸入的是ASCII碼,那么就不要勾選 Hex Display Mode
          如果輸入的是16進制,那么就不要勾選 Hex Display Mode

          Clear Screen 是清屏
          Echo Typed Characters 是你在虛擬終端窗口輸入字符時,輸入的字符顯示在虛擬終端窗口上。



          具體C程序如下(如有疑問聯系本人,新浪微博地址:
          http://t.sina.com.cn/1858560312):
          #include
          #include
          #define uint unsigned int
          #define uchar unsigned char
          unsigned char a,flag;
          char code YD[]={


          0x01,0x00,0x01,0x00,0x7F,0xFC,0x03,0x80,
          0x05,0x40,0x09,0x30,0x31,0x0E,0xDF,0xE4,
          0x00,0x80,0x01,0x00,0x7F,0xFE,0x01,0x00,
          0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,


          0x20,0x40,0x30,0x40,0x24,0x4C,0x42,0x70,
          0xFF,0x44,0x42,0x46,0x00,0x7C,0x7E,0x00,
          0x42,0x40,0x7E,0x4C,0x42,0x70,0x7E,0x40,
          0x42,0x44,0x42,0x46,0x4A,0x3C,0x44,0x00,


          0x00,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0,
          0x08,0x10,0x0F,0xF0,0x00,0x00,0xFF,0xFE,
          0x01,0x00,0x09,0x00,0x09,0xF8,0x09,0x00,
          0x15,0x00,0x23,0x00,0x40,0xFE,0x00,0x00,


          0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x40,
          0x04,0x20,0x09,0x18,0x11,0x0E,0x61,0x04,
          0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
          0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,


          0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
          0x01,0x00,0xFF,0xFE,0x01,0x00,0x02,0x80,
          0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,
          0x08,0x10,0x10,0x18,0x20,0x0E,0x40,0x04,/


          0x08,0x20,0x08,0x20,0x08,0x20,0x4B,0xFE,
          0x4A,0x22,0x4A,0x22,0x4A,0x22,0x4A,0x22,
          0x4A,0x22,0x4A,0x22,0x4A,0x22,0x12,0x2E,
          0x12,0x24,0x20,0x20,0x40,0x20,0x80,0x20,


          0x00,0x00,0x7F,0xFC,0x00,0x10,0x1F,0x90,
          0x10,0x90,0x1F,0x90,0x10,0x90,0x00,0x04,
          0xFF,0xFE,0x00,0x10,0x1F,0x90,0x10,0x90,
          0x1F,0x90,0x10,0x90,0x00,0x50,0x00,0x20
          };


          void delay(uint z)
          {
          uint x,y;
          for(x=z;x>0;x--)
          for(y=110;y>0;y--);
          }

          void main()
          {
          int i;
          TMOD=0x20;//設置定時器1為工作方式2
          TH1=0xfd;
          TH2=0xfd;//設置波特率為9600
          TR1=1;//啟動定時器1
          SM0=0;
          SM1=1;//選擇串口工作方式1
          REN=1;//允許接收數據
          EA=1;//打開總中斷
          ES=1;//打開串口中斷

          while(1)
          {
          if(flag==1)
          {
          flag=0;
          while(1)
          {
          if(a==0x31)//鍵盤碼十六進制
          {
          for(i=0;i<16;i++)
          {
          P1=i;
          P0=~YD[2*i];
          P2=~YD[2*i+1];
          delay(2);
          }
          }

          if(a==0x32)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[32+2*i];
          P2=~YD[32+2*i+1];
          delay(2);

          }
          }

          if(a==0x33)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[64+2*i];
          P2=~YD[64+2*i+1];
          delay(2);
          }
          }

          if(a==0x34)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[96+2*i];
          P2=~YD[96+2*i+1];
          delay(2);
          }
          }

          if(a==0x35)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[128+2*i];
          P2=~YD[128+2*i+1];
          delay(2);
          }
          }

          if(a==0x36)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[160+2*i];
          P2=~YD[160+2*i+1];
          delay(2);
          }
          }

          if(a==0x37)
          {
          for(i=1;i<17;i++)
          {
          P1=i;
          P0=~YD[192+2*i];
          P2=~YD[192+2*i+1];
          delay(2);
          }
          }

          }//第二個while結尾
          }//if結尾
          }//第一個while結尾
          }//主函數結尾

          void ser() interrupt 4
          {
          RI=0;//接受中斷標志位,清0為取消中斷申請
          a=SBUF;//接收數據
          flag=1;//中斷標志位
          }



          評論


          技術專區(qū)

          關閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();