阅读:1877回复:5
CY7C68013+CPLD,发送数据一直出现挂起现象
我用68013和CPLD95144做了个2.0的接口,实现数据上下传输。自己的CPLD 程序前后仿真波形都正确,但是使用CYPRESS的界面传输数据,每次都是传两次就出现PENDING 情况,请问高手,这是什么原因造成的?CPLD程序没有正常工作还是硬件电路的问题呢?
|
|
最新喜欢:ltaor |
沙发#
发布于:2003-09-13 11:38
你用的端点是双缓冲吧,那就是说你的cpld根本就没有把数据读走!因此你最多只能发两个512的包到设备,只能等到端点空了再能在发数据下去
你用的什么方式? slavefifo?如果是就查查你的设置吧 如果使用8051控制,就看你读端点给cpld送数那一块是否出了问题。 祝你好运! |
|
板凳#
发布于:2003-09-13 13:26
我用的是SLAVEFIFO形式,但是我用逻辑分析仪测量FIFOADDR[0:1],发现我每次通过不同的管道传输数据的时候,FIFOADDR都能指向相应的地址,这就说明CPLD程序实际是跑起来了啊。下面是我CPLD的程序:
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity artribute is Port (--system signal--- clk :in std_logic; rst :in std_logic; --connect to dsp-- dspflag :in std_logic; -- arbenable:in std_logic; datato51 :out std_logic_vector(7 downto 0); --interface with fx2-- sloe :out std_logic; slrd :out std_logic; slwr :out std_logic; pktend :out std_logic; flaga :in std_logic; flagb :in std_logic; flagc :in std_logic; flagd :in std_logic; datafromfx2: inout std_logic_vector(7 downto 0); fifoadr :out std_logic_vector(1 downto 0); -- fifoadrtest:out std_logic_vector(1 downto 0); ledout : out std_logic_vector(7 downto 0) -- datatest: out std_logic_vector(7 downto 0) -- ep2flag :out std_logic; -- ep4flag :out std_logic; -- ep6flag :out std_logic; -- ep8flag :out std_logic ); end artribute; architecture Behavioral of artribute is type statetype is (idle,cyidle, cywrs1, cywrs2, cywrs3,cywrs4); signal present_state, next_state: statetype; --signal value: std_logic_vector (7 downto 0); signal clk1: std_logic; signal count: std_logic_vector (7 downto 0); signal empty: std_logic; signal full : std_logic; signal epn : std_logic_vector(1 downto 0); --signal selectad:std_logic_vector(1 downto 0); signal wenable:std_logic; signal renable:std_logic; signal flag: std_logic_vector(2 downto 0); --signal renable_1: std_logic; --signal wenable_1: std_logic; --signal reflag : std_logic; --signal weflag : std_logic; signal x : std_logic; signal arbenable: std_logic; signal testdata : std_logic_vector(7 downto 0); --signal trigger : std_logic; begin state_frequence: process(clk) begin if rst=\'0\' then clk1 <=\'0\'; elsif(clk\'event and clk=\'1\')then clk1 <= not clk1; end if; end process state_frequence; assignment: process(clk) begin flag <= flagb & flaga & flagd; x <= renable and wenable; end process assignment; arb: process(arbenable,flag) begin if(arbenable=\'0\')then -- trigger<=\'0\'; case flag is when \"111\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"01\"; empty <=flagb; -- trigger<= not trigger; when \"110\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"01\"; empty <=flagb; -- trigger<= not trigger; when \"101\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"01\"; empty <=flagb; -- trigger<= not trigger; when \"100\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"01\"; empty <=flagb; -- trigger<= not trigger; when \"011\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"00\"; empty <=flaga; -- trigger<= not trigger; when \"010\"=> renable<=\'0\'; wenable<=\'1\'; epn <=\"00\"; empty <=flaga; -- fifoadrtest<=epn; -- trigger<= not trigger; when \"001\"=> if (dspflag=\'1\') then wenable<=\'0\'; renable<=\'1\'; epn <=\"11\"; -- fifoadrtest<=epn; full <=flagd; -- trigger<= not trigger; else wenable <=\'1\'; renable <=\'1\'; end if; when others=> renable<=\'1\'; wenable<=\'1\'; end case; end if; end process arb; -- LED :process(clk1,rst) -- variable counter: INTEGER; -- begin -- if (rst=\'0\') then -- ledout <=\"00000000\"; -- counter:=0; -- else -- counter:=counter+1; -- if(counter=8000) then -- ledout <=\"11111111\"; -- counter:=counter+1; -- elsif(counter=16000) then -- ledout <=\"00000000\"; -- counter:=0; -- end if; -- end if; -- end process LED; readfx2:process(present_state,flag,x) begin case present_state is when idle => sloe <=\'1\'; slrd <=\'1\'; slwr <=\'1\'; pktend <=\'1\'; datafromfx2 <=\"11111111\"; if ( x=\'0\') then next_state <=cyidle; -- testdata <=\"11111111\"; testdata <=testdata+\'1\'; else next_state <= idle; end if; when cyidle => next_state <=cywrs1; if (renable=\'0\') then sloe <=\'1\'; slrd <=\'1\'; fifoadr <=epn; datato51 <=\"00000000\"; elsif(wenable=\'0\') then slwr <=\'1\'; -- fifoadr <=epn; fifoadr <=epn; -- cyrds3count <=\'0\'; -- value <=\"00000000\"; datafromfx2 <=\"00000000\"; pktend <=\'1\'; -- next_state <=cywrs1; end if; when cywrs1 => fifoadr <=epn; next_state <=cywrs2; when cywrs2 => if (renable=\'0\') then if(empty=\'1\') then next_state <=cywrs3; else next_state <=cywrs2; end if; elsif(wenable=\'0\') then if(full=\'1\') then next_state <=cywrs3; pktend <=\'1\'; -- value <=count; else next_state <=cywrs2; end if; elsif(x=\'1\') then next_state <=idle; end if; when cywrs3 => if (renable=\'0\') then if(empty=\'0\') then next_state <=cyidle; else datato51 <= datafromfx2; sloe <=\'0\'; slrd <=\'0\'; next_state <=cywrs4; end if; elsif(wenable=\'0\') then pktend <=\'1\'; if(full=\'0\') then next_state <=cyidle; else datafromfx2 <=count; slwr <=\'0\'; next_state <=cywrs4; end if; elsif(x=\'1\') then next_state <=idle; end if; when cywrs4 => if (x=\'0\') then next_state <=cywrs1; if (renable=\'0\') then sloe <=\'1\'; slrd <=\'1\'; elsif (wenable=\'0\') then pktend <=\'1\'; slwr <=\'1\'; end if; else next_state <= idle; end if; when others => null; end case; end process readfx2; artributeenable: process(rst) begin if(rst\'event and rst=\'0\') then arbenable <=\'0\'; end if; end process artributeenable; state_clocked: process(rst,clk1) begin if(rst=\'0\')then count <=\"00000000\"; present_state <=idle; elsif (clk1\'event and clk1=\'1\') then present_state <=next_state; count <=count+\'1\'; -- datatest <=count; end if; end process state_clocked; end Behavioral; 从上面的程序可以看出,我的CPLD程序至少应该跑到CYIDLE状态了,否则FIFOADDR不会有相应的地址信号出现,而从上面的程序分析,进入了IDLE状态,就会开始读数据啊。请兄弟再次指点。缓存我也用的是双缓存形式。 |
|
地板#
发布于:2003-09-13 23:32
呵呵,我不懂cpld,你跟我说我也不明白呀
还有你是上传还是下传,要是下传的话检查一下你slave fifo的sloe,slcs,slrd是否正确,还有你的flaga flagb flagc是否有问题,相关寄存器是ifconfig,FIFOPINPOLAR,EP2FIFOPFH,EP2FIFOCFG,看这些寄存器设置是否和你的实际情况相符等等。 |
|
地下室#
发布于:2005-05-08 23:51
我知道最可能的原因:
因为你采用的是手动模式, 在读取后没有清空buf 如清空ep6: SYNCDELAY; OUTPKTEND = 0x86; |
|
5楼#
发布于:2005-05-09 10:59
ok
|
|