VHDL串口程序有误码

[复制链接]
2227|5
 楼主| wajtmusic 发表于 2012-8-8 13:33 | 显示全部楼层 |阅读模式
用VHDL编写的串口接收程序,有时候会接收不到PC下发的数据,平均100次大概有1次接收不到。process(clk)
begin
  if clk'event and clk='1' then
   case st1 is

when 0=>if rxd<='0' then


st1<=1;

else

if cont='1' then
--cont=1则清除串口接收的数据

  reg<=(others=>'0');



end if;

end if;

when 1=>if cz<8 then

cz<=cz+1;

reg_m(7)<=rxd;

reg_m(6 downto 0)<=reg_m(7 downto 1);
--接收数据并存储

else reg<=reg_m;cz<=(others=>'0');st1<=0;



end if;

when others=>st1<=0;



   end case;
  end if;
end process;
mr.king 发表于 2012-8-8 21:21 | 显示全部楼层
很显然,对于接收异步信号,必须要用高于波特率的时钟去采样,一般是8--16倍,最差3倍,你用同频采样肯定不稳定
shell.albert 发表于 2012-8-9 10:22 | 显示全部楼层
使用更高的频率去采样,并且在中间的频率处进行采样,这样更可靠。
 楼主| wajtmusic 发表于 2012-8-20 16:52 | 显示全部楼层
经过修改采样时钟后,现在接收正常,感谢2楼,感谢3楼,感谢版主,感谢21ic。。。。。。
GoldSunMonkey 发表于 2012-8-20 22:23 | 显示全部楼层
GoldSunMonkey 发表于 2012-8-20 22:23 | 显示全部楼层
还有我的事情。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

263

主题

754

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部