完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
上位机使用labview与下位机FPGA进行双向通讯,波特率128000。程序运行十来秒后,上位机可以正常接收下位机发来的信号,但是下位机无法接收到上位机发来的信号,用示波器测了一下,串口线路中是有信号,所以本人分析是下位机串口接受程序出现了问题,或者有其他解决方法,求大神指点!
附下位机串口接受程序(借鉴的): library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity reciever is --generic(framlenr:integer:=8); --传送的数据位为8位 Port ( bclkr,rxdr:in std_logic; --定义输入输出信号 r_ready:out std_logic; rbuf:out std_logic_vector(7 downto 0) ); end; architecture Behavioral of reciever is type states is (r_start,r_center,r_wait,r_sample,r_stop);--定义各子状态 signal state:states:=r_start; signal rxd_sync:std_logic; -- rxd_sync内部信号,接受rxd输入 signal resetr:std_logic:='0'; begin pro1:process(rxdr) begin if rxdr='0' then rxd_sync<='0'; else rxd_sync<='1'; end if; end process; pro2:process(bclkr,resetr,rxd_sync) --主控时序、组合进程 variable count:std_logic_vector(3 downto 0); --定义中间变量 variable rcnt:integer:=0; -- rcnt为接收的数据位数计数 variable rbufs:std_logic_vector(7 downto 0); begin if resetr='1' then state<=r_start; count:="0000"; --复位 elsif rising_edge(bclkr) then --波特率信号的上升沿 --状态机 case state is when r_start=> --状态1,等待起始位 if rxd_sync='0' then state<=r_center; r_ready<='0'; rcnt:=0; else state<=r_start; r_ready<='0'; end if; when r_center=> --状态2,求出每位的中点 if rxd_sync='0' then --每个数据位被分为16等分,中点为8 if count="0110" then state<=r_wait; count:="0000"; else count:=count+1; state<=r_center; end if; else state<=r_start; end if; when r_wait=> --状态3,等待状态 if count>="1110" then if rcnt=8 then state<=r_stop; -- rcnt=framlenr表示数据接收够8位 else state<=r_sample; end If; count:="0000"; else count:=count+1; state<=r_wait; end if; when r_sample=>rbufs(rcnt):=rxd_sync; --状态4,数据位采样检测 rcnt:=rcnt+1; state<=r_wait; when r_stop=>r_ready<='1'; rbuf<=rbufs; --状态5,输出帧接收完毕信号 state<=r_start; when others=>state<=r_start; end case; end if; end process; end Behavioral; |
|
相关推荐
3个回答
|
|
我用led显示r_ready端口,正常时是闪烁的,异样后就保持不变了
|
|
|
|
vhdl不懂,看着费劲。。
|
|
|
|
只能建议lz用signaltap来观察相关的信号了。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
求FPGA 驱动控制ltc2271 或者 ltc2180 或者 ltc2190或者 ltc2202 的代码
1040 浏览 0 评论
372 浏览 0 评论
求助:遇见诡异问题,FPGA模块A输出端口连接模块B输入后,模块A不能正常工作的
1207 浏览 1 评论
425 浏览 0 评论
1154 浏览 1 评论
4042 浏览 91 评论
浏览过的版块 |
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-8 23:15 , Processed in 0.527435 second(s), Total 75, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号