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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計

          FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計

          作者: 時間:2010-08-31 來源:網(wǎng)絡(luò) 收藏

          摘要:本文針對由構(gòu)成的高速數(shù)據(jù)采集系統(tǒng)數(shù)據(jù)處理能力弱的問題,提出實現(xiàn)數(shù)據(jù)串行通信的解決方案。在通信過程中完全遵守RS232協(xié)議,具有較強的通用性和推廣價值。
          1 前言
          現(xiàn)場可編程邏輯器件()在高速采集系統(tǒng)中的應(yīng)用越來越廣,由于FPGA對采集到的數(shù)據(jù)的處理能力比較差,故需要將其采集到的數(shù)據(jù)送到其他CPU系統(tǒng)來實現(xiàn)數(shù)據(jù)的處理功能,這就使FPGA系統(tǒng)與其他CPU系統(tǒng)之間的數(shù)據(jù)通信提到日程上,得到人們的急切關(guān)注。本文介紹利用VHDL語言實現(xiàn) FPGA與的串口異步通信電路。
          整個設(shè)計采用模塊化的設(shè)計思想,可分為四個模塊:FPGA數(shù)據(jù)發(fā)送模塊,F(xiàn)PGA波特率發(fā)生控制模塊,F(xiàn)PGA總體接口模塊以及數(shù)據(jù)接收模塊。本文著重對FPGA數(shù)據(jù)發(fā)送模塊實現(xiàn)進行說明。
          2 FPGA數(shù)據(jù)發(fā)送模塊的設(shè)計
          根據(jù)RS232 異步串行通信來的幀格式,在FPGA發(fā)送模塊中采用的每一幀格式為:1位開始位 8位數(shù)據(jù)位 1位奇校驗位 1位停止位,波特率為2400。本系統(tǒng)設(shè)計的是將一個16位的數(shù)據(jù)封裝成高位幀和低位幀兩個幀進行發(fā)送,先發(fā)送低位幀,再發(fā)送高位幀,在傳輸數(shù)據(jù)時,加上文件頭和數(shù)據(jù)長度,文件頭用555555來表示,只有單片機收到555555時,才將下面?zhèn)鬏數(shù)臄?shù)據(jù)長度和數(shù)據(jù)位進行接收,并進行奇校驗位的檢驗,正確就對收到的數(shù)據(jù)進行存儲處理功能,數(shù)據(jù)長度可以根據(jù)需要任意改變。由設(shè)置的波特率可以算出分頻系數(shù),具體算法為分頻系數(shù)X=CLK/(BOUND*2)??捎纱耸剿愠鏊璧娜我獠ㄌ芈省O旅媸菍崿F(xiàn)上述功能的VHDL源程序。
          Library ieee;
          use ieee.std_logic_1164.all;
          use ieee.std_logic_arith.all;
          use ieee.std_logic_unsigned.all;
          entity atel2_bin is
          port( txclk: in std_logic; --2400Hz的波特率時鐘
          reset: in std_logic; --復位信號
          din: in std_logic_vector(15 downto 0); --發(fā)送的數(shù)據(jù)
          start: in std_logic; --允許傳輸信號
          sout: out std_logic --串行輸出端口
          );
          end atel2_bin;
          architecture behav of atel2_bin is
          signal thr,len: std_logic_vector(15 downto 0);
          signal txcnt_r: std_logic_vector(2 downto 0);
          signal sout1: std_logic;
          signal cou: integer:=0;
          signal oddb:std_logic;
          type s is(start1,start2,shift1,shift2,odd1,odd2,stop1,stop2);
          signal state:s:=start1;
          begin
          process(txclk)
          begin
          if rising_edge(txclk) then
          if cou3 then thr=0000000001010101; --發(fā)送的文件頭
          elsif cou=3 then
          thr=0000000000000010; --發(fā)送的文件長度
          elsif (cou>3 and state=stop2) then thr=din;--發(fā)送的數(shù)據(jù)
          end if;
          end if;
          end process;
          process(reset,txclk)
          variable tsr,tsr1,oddb1,oddb2: std_logic_vector(7 downto 0);


          上一頁 1 2 3 下一頁

          關(guān)鍵詞: EDA FPGA 單片機

          評論


          相關(guān)推薦

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

          關(guān)閉
          看屁屁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); })();