Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > problem about 68013A's slave fifo to FPGA

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



problem about 68013A's slave fifo to FPGA
Moderator:
RSKV

Post Reply
Follow this topic



problem about 68013A's slave fifo to FPGA

wanta posted on 02 Jul 2012 12:16 AM PST
Member
3 Forum Posts

 hi,

I am using Win7 + Suite USB 3.4.7 + 68013A PVX 56 + slave FIFO + (FPGA) Cyclone II,

I use CyConsole input" 1 2 3 4 5 6 7 8 9" , to EP2 , but I read "2 4 6 8" from EP6,

half data lose! anyone can help me ? thanks!

below is my  firmware and verilog code:

=============================================================

 

// Called once at startup

    CPUCS = 0x10; // CLKSPD[1:0]=10, for 48MHz operation, output CLKOUT

    IFCONFIG = 0xE3; 

REVCTL=0x01;

// 48 MHz internal clock source, drive IFCLK, synchronous slave FIFO mode

  PINFLAGSAB = 0x08;    // FLAGA - EP6 FULL flag

    SYNCDELAY;

PINFLAGSCD = 0xE0;    // FLAGD - EP2 Emtpy flag

    SYNCDELAY;

    PORTACFG |= 0x80;

    EP4CFG = 0x02;               //clear the valid bits on ep4 and ep8

    SYNCDELAY;                 

EP8CFG = 0x02;                

SYNCDELAY;                    

EP2CFG = 0xA2;                // OUT, 512-bytes, 4x, bulk

    SYNCDELAY;                    

EP6CFG = 0xE2;                // IN, 512-bytes, 4x, bulk

    SYNCDELAY;

FIFORESET = 0x80;             // activate NAK-ALL to avoid race conditions

    SYNCDELAY;                    // see TRM section 15.14

    FIFORESET = 0x02;             // reset, FIFO 2

    SYNCDELAY;                    //

    FIFORESET = 0x04;             // reset, FIFO 4

   SYNCDELAY;                    //

    FIFORESET = 0x06;             // reset, FIFO 6

    SYNCDELAY;                    //

    FIFORESET = 0x08;             // reset, FIFO 8

    SYNCDELAY;                    //

    FIFORESET = 0x00;             // deactivate NAK-ALL

    // handle the case where we were already in AUTO mode...

    // ...for example: back to back firmware downloads...

    SYNCDELAY;                    //

    EP2FIFOCFG = 0x00;            // AUTOOUT=0, WORDWIDE=0

  

  // core needs to see AUTOOUT=0 to AUTOOUT=1 switch to arm endp's

  

  SYNCDELAY;                    //

    EP2FIFOCFG = 0x10;            // AUTOOUT=1, WORDWIDE=0

  

  SYNCDELAY;                    //

    EP6FIFOCFG = 0x0C;            // AUTOIN=1, ZEROLENIN=1, WORDWIDE=0, INFM = 1;

    SYNCDELAY;

 

=======================================================================================

 

 

module fpga_master

(

input clk,

input rst_n,

input flaga, //EP2 empty flag

input flagd, // EP6 full flag

output reg [1:0] faddr,

output reg sloe,

output reg slrd,

output reg slwr,

inout [7:0]fdata,

 

output led,

output beep

);

 

(* noprune *)reg [25:0] counter;

 

assign led =counter[25];

 

assign beep =1;

 

 

reg link = 0; //link控制三态门

(* noprune *)reg [7:0]fdata_reg = 0;

assign fdata = link ? fdata_reg:8'bz;

 

 

(* noprune *)reg [3:0] state = 0;

(* noprune *)reg [31:0] recv_count = 0;

(* noprune *)reg [31:0] send_count = 0;

(* noprune *)reg [7:0] fifodata = 0;

 

always@(posedge clk)

begin

counter <= counter + 26'b1;

end

 

(* noprune *) reg [7:0] temp[15:0];

 

 

always@(posedge clk)

begin

case(state)

0: 

begin

 faddr <= 2'b00;

 sloe  <= 0;                               // IDLE STATE

 link  <= 0;

 slrd  <= 1;

 slwr  <= 1;

 state <= 1;

end

1:

begin

if(flaga == 1) // not empty

begin      

 slrd  <= 0;

 state <= 2;

end

else

begin

 slrd  <= 1;

 state <= 0;

end

end

2:

begin

fifodata = fdata;

temp[recv_count] = fdata;

recv_count = recv_count +1;

faddr <= 2'b10;        // ep6

link  <= 1;

sloe  <= 1;

state <= 3;

end

3:

begin

if(flagd == 1) // not full

state <= 4;

else

state <= 3;

 

fdata_reg <= fifodata;

end

4:

begin

slwr  <= 0;

send_count <= send_count +1;

state <= 0;

end

default:

state<=0;

 

endcase

end

 

 

endmodule

 

 




Re: problem about 68013A's slave fifo to FPGA

RSKV posted on 02 Jul 2012 02:45 AM PST
Cypress Employee
851 Forum Posts

 Hi Wanta,

From your description, I understood that you are transferring some data from Cy Console to FX2LP EP2 and then your FPGA is reading this data.

Once you receive this data in FPGA, you are writing it back to FX2 EP6 and then you are trying to read this data using Cy Console. Please correct me if I am wrong.

From the behavior that you are observing, it is looking like you are missing every alternate sample of data. Check the data that you received in the FPGA to find out whether you are missing that sample while reading or during writing that back to EP6.

Regards,

sai krishna.



Re: problem about 68013A's slave fifo to FPGA

wanta posted on 02 Jul 2012 03:06 AM PST
Member
3 Forum Posts

 Hi,RSKV

Thank you for reply, You are right, I use fpga loopback FX2LP, using salve fifo x8

I watch register when fpga read byte from FX2LP, a byte will  losed when read from EP2, EP6 is filled right

It looks like read one word instead byte, but I config EP2FIFOCFG = 0x10;

 

Does need power off then power on FX2LP when I download new firmware?

thanks



Re: problem about 68013A's slave fifo to FPGA

RSKV posted on 02 Jul 2012 03:24 AM PST
Cypress Employee
851 Forum Posts

 Yes, you need to reset the device to download new firmware.

 



Re: problem about 68013A's slave fifo to FPGA

wanta posted on 02 Jul 2012 03:31 AM PST
Member
3 Forum Posts

 Thank you very much!

Maybe my FX2LP is broken :(

 



Re: problem about 68013A's slave fifo to FPGA

RSKV posted on 02 Jul 2012 03:40 AM PST
Cypress Employee
851 Forum Posts

Please let me know the reason why you are thinking that FX2LP is broken.

Are you unable to download the code now?.

Regards,

sai krishna.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20