FPGA學習之串口接收模塊


FPGA學習之串口接收模塊

原文弊端,串口每次只能接受一個,再接受需要先關閉串口再打開才有效。(可能是軟件問題,換一個之后OK)

首先是改波特率,例程為9600,改成115200.

115200 bps 傳輸速度使一位數據的周期是 0.0000086805s 。以 50Mhz 時鍾頻率
要得到上述的定時需要:
N = 0.0000086805 / ( 1 / 50Mhz ) = 434

 1 module rx_bps_module
 2 (
 3  CLK, RSTn,Count_Sig, BPS_CLK
 4 
 5 );
 6 input CLK;
 7 input RSTn;
 8 input Count_Sig;
 9 output BPS_CLK;
10 
11 /******************************/
12 
13 reg [12:0]Count_BPS; 
14 
15 /******************************/
16 
17  always @ ( posedge CLK or negedge RSTn )
18          if( !RSTn )
19           Count_BPS <= 13'd0;
20          // else if(Count_BPS == 13'd5207 )// 9600  bps  傳輸一位數據時間
21           else if(Count_BPS == 13'd433 )// 115200  bps  傳輸一位數據時間
22               Count_BPS <= 13'd0;
23          else if( Count_Sig )  //計數信號使能
24              Count_BPS <= Count_BPS + 1'b1;
25          else
26              Count_BPS <= 13'd0;//計數信號no使能
27         
28      /********************************/
29    assign BPS_CLK = ( Count_BPS == 12'd217 ) ? 1'b1 : 1'b0;//一個周期的二分之一時間時,產生一個高脈沖
30 
31     /*********************************/
32 
33 
34 
35 
36 endmodule

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM