UART 接收模块

本文档详细介绍了UART接收模块的设计与实现,包括实验要求、原理和VHDL代码实现。通过过采样16次并取中间6次数据来判断电平,避免信号干扰。在Quartus II中进行了仿真,并通过板级验证确保了模块的正确运行。
摘要由CSDN通过智能技术生成

(已通过板级验证)

实验要求:

在Quartus ii 中利用In system sources and probes(ISSP) 查看UART接收模块接收到的数据,串口接收到的数据由PC机发出。
baud_set[2:0]: 波特率选择信号
rs232_rx:串行数据输入
data_byte[7:0] : 并行数据输出
rx_done: 脉冲信号,接收结束信号
diagram

实验原理:

一般在实验室环境下,信号比较稳定,不存在强电磁干扰。 但是在工业环境下,信号会有一定的错误,因此我们采用过采样的办法避免干扰。 对每一个数据进行多次采样,然后取中间的数据判断为高电平还是低电平。例: 本次实验过采样16次,取中间的6次采样数据(最稳定)。如果6次累加<3,则判断为低电平,如果6次累加>3则判断为高电平(本实验未考虑3次1,3次0的情况)。

oversampling

VHDL实现

和uart 发送模块类似:

baud LUT

-----------------10^9 ns/ 9600 / 20 ns / 16 = 325-----------------------
process(clk)
begin
	if( nrst = '0') then
		baud_bps<= 0;
	else if( rising_edge(clk)) then
		case( baud_set ) is
			when	"000"		=>		baud_bps<= 10416;			-- 300
			when 	"001"		=>		baud_bps<= 2603;			--	1200
			when	"010"		=>		baud_bps<= 1301;			-- 2400
			when	"011"		=>		baud_bps<= 325;			-- 9600
			when	"100"		=>		baud_bps<= 162;			-- 19200
			when	"101"		=>		baud_bps<= 80;				-- 38400
			when	"110"		=>		baud_bps<= 53;				-- 57600
			when	"111"		=>		baud_bps<= 26;				-- 115200
			when others		=>		baud_bps<= 0;
		end case;
			end if;
	end if;
end process;

DIV_CNT

-------------- DIV_CNT ----------------------
process(clk)
begin
	if( nrst ='0' ) then
		div_cnt<=0;
	else if(rising_edge(clk)) then
				if( rx_state = '1' ) then					-- start counting when the uart is working
						if( div_cnt	= baud_bps) then		--- cnt from 0 to baud_bps
								div_cnt<= 0;
						else
							div_cnt<=div_cnt+
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值