FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計_第1頁
FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計_第2頁
FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計_第3頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、【W(wǎng)ord版本下載可任意編輯】 FPGA與單片機實現(xiàn)數(shù)據(jù)RS232串口通信的設(shè)計 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; -復(fù)位信號 din: in std_logic_vector(15 downto 0); -發(fā)送的數(shù)據(jù) start: in std_logic

2、; -允許傳輸信號 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,o

3、dd2,stop1,stop2); signal state:s:=start1; begin process(txclk) begin if rising_edge(txclk) then if cou3 and state=stop2) then thr if start=1 then if cou=3 then len0); state -奇校驗位 if ddb=1 then sout1 sout1 tsr1:=thr(15 downto 8); oddb2:=thr(15 downto 8); sout1 -奇校驗位 if ddb=1 then sout1 sout1=1; -停止位

4、if len=0000000000000000 then state=stop2; else state=start1; len=len-1; end if; end case; end if; end process; sout=sout1; end behav; 其中各信號的說明已在程序中標明了。波形仿真圖如圖1所示。 wt 圖1 FPGA數(shù)據(jù)發(fā)送時序仿真圖 圖中Din寫入值為3355H,波特率為2400Hz,Start信號始終置邏輯1,即隨時都能發(fā)送數(shù)據(jù)。Reset信號邏輯1時復(fù)位,邏輯0時電路開始工作。THR是數(shù)據(jù)存放器,文件頭、數(shù)據(jù)長度以及數(shù)據(jù)位都先存放到THR中,Len是數(shù)據(jù)長度,TSR是低8位數(shù)據(jù)幀存放器,TSR1是高8位數(shù)據(jù)幀存放器。數(shù)據(jù)長度Len定為02H,發(fā)送時先發(fā)送低8位55H,后發(fā)送高8位33H,一共發(fā)送兩遍。發(fā)送的數(shù)據(jù)格式說明:當發(fā)送55H時,其二進制為01010101,則發(fā)送的數(shù)據(jù)的二進制數(shù)為00101010111(1位開始位 8位數(shù)據(jù)位 1位奇校驗位 1位停止位)。 單片機部分先對FPGA發(fā)送過來的文件頭開展確認,正確就接收文件,否則放棄接收的數(shù)據(jù)。根據(jù)FPGA發(fā)送模塊的協(xié)議,對串口控制存放器SCON和波特率控制存放器PCON的設(shè)置即可實現(xiàn)。 3 總結(jié) 目前電子產(chǎn)品的

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論