求助:两路频率输出,一路不正常
2012年09月19日 18:38 发布者:zhangjin1986
各位大侠:我有一个程序,输入频率为1kHz,另有两个输入口接了拨码开关(拨码开关ON接地,OFF悬空)。通过输入"00","01","10","11"来让输出口输出500Hz,250Hz,125Hz,67.5Hz。
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
Entity fen is
port( xh:in std_logic;
ds:in std_logic_vector(1 downto 0);
sc:out std_logic);
End fen;
Architecture fenpin of fen is
Signal data:std_logic_vector(3 downto 0);
begin
yi:process(xh)
begin
if(xh'event and xh='1') then
data<=data+1;
end if;
end process;
er:process(ds,data)
begin
case ds is
when "00"=>sc<=data(0);
when "01"=>sc<=data(1);
when "10"=>sc<=data(2);
when "11"=>sc<=data(3);
when others=>NULL;
end case;
end process;
end fenpin;
我用的芯片是EPM7064STC44-10,xh为40脚,sc为6脚,ds为10脚,ds为11脚。只有“00”与“10”时能输出500Hz与125Hz,而"01"与"11"不正常,也就是说当拨码开关的1脚接地时,拨码开关的2脚接地与悬空能正常输出频率;当拨码开关的1脚悬空时,输出频率就不正常了。这是为什么?请大侠们指点。谢谢!
网友评论
ty1932 2012年09月29日
是不是要补上拉电阻啊? 你端口配置的什么接口啊?
是不是要补上拉电阻啊? 你端口配置的什么接口啊?
wccd1 2013年04月08日
最好要补上上拉电阻。
最好要补上上拉电阻。
lelee007 2013年04月10日
帮不上忙,呵呵,只用verilog,不懂vhdl
帮不上忙,呵呵,只用verilog,不懂vhdl
看看你的ds能不能变成高电平!