Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kevin_Fan
Level 1
Level 1
10 sign-ins First reply posted 5 sign-ins

Hello,

We are using FX3 to realize the communication between FPGA and our host computer, and we hope to use GPIF II master mode to control the data transmission of FPGA. We assume the following scheme:

we use a MANUAL_IN DMA channel between GPIF and USB bulk in endpoint.

(1) At the beginning, the GPIFII state machine is in a waiting state. Do not write data to the DMA buffer at this time;

(2) When the Host application, such as Control Center, needs 256 bytes of data, click Transfer Data In, then the state machine change to a new state, and starts InData action;

(3) After clicking Transfer Data In, FX3 needs to send a signal to FPGA,   we call it BEGIN signal here;

(4) When the BEGIN signal is high, the FPGA writes data to the 32-bit data line of GPIF II; After 256 bytes of data is written, the BEGIN signal becomes low, the FPGA stops writing data, and the GPIF state machine returns to the wait state.

In short, we hope that FX3 can control the FPGA according to the data size filled in the host application, and let the FPGA write the corresponding size of data to the DMA buffer.

Is the above idea feasible?  if yes, how to set the  GPIF state machine,  to write data into DMA buffer only when the host application needs data?

If not, is there any good suggestion that FX3 can transfer the latest data collected by FPGA to the host  every time the host  needs data?(Our FPGA is used for data acquisition and will be in a continuous working state. At first, we adopted a scheme similar to AN65974, but because the host computer could not take out the data in time, the FPGA has to stop writing the data when DMA buffer is full, and our users did not want this)

Or, can you give us some other plans or suggestions? 

Thank you,

Fan

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Fan,

"If I want to send the information through GPIF II, what I should do? Do I need to set a bulk out endpoint and send the information to FPGA through DMA channel?"
>> Yes, but make sure the FPGA is notified to read the data when its available.

"How to modify the buffer size to be same as the data? "
>> When you request data of a specified amount from the device, you can send the length required as one of the values in the data.

When buffer size has to be modified, destroy the current DMA channel, change the buffer size in CyU3PDmaChannelConfig_t with the value sent from the host and then create the DMA channel again. 

There is no need to preset DMA buffer size. What I am trying to say is, you can declare the CyU3PDmaChannelConfig_t as global, and preset all other parameters of the structure except the size. Whenever a request comes from the host for a certain bytes of data, set the size to that value and create the channel with setXfer. Make sure to destroy the current DMA channel, when a new request from host comes. 

I would recommend you to try out the first method first. As the second may results in timing issues.

Best Regards,
AliAsgar

 

View solution in original post

0 Likes
4 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Fan,

From your application, I can think of two possibilities to implement the solution:

When host asks for a certain bytes of data, that information can be sent to the FPGA through GPIF II or any other peripherals like UART, I2C, SPI. FPGA can read this value and then send out that many bytes of data on the GPIF II interface based on the FX3 Flag status.

2. Whenever host requests for IN data, the DMA channel can be reset and the DMA buffer size can be modified to be exactly same as the amount of data needed from the FPGA and can be activated again. After activating, a BEGIN signal can be asserted using a GPIO (connected to FPGA) and then the FPGA can start sending data. Once a PROD event is received for the DMA channel, the transfer can be stopped.

Out of two, first solution seems more feasible.

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar,

Thanks for your reply! 

-In the first solution: "when host asks for a certain bytes of data, that information can be sent to the FPGA through GPIF II or any other peripherals"

If I want to send the information through GPIF II, what I should do? Do I need to set a bulk out endpoint and send the information to FPGA through DMA channel?

-In the second solution, you mentioned that the DMA channel can be reset and the DMA buffer size can be modified

How to modify the buffer size to be same as the data? 

My understanding is:when I want to modify the buffer size, I should first use CyU3PDmaChannelReset() to reset the DMA channel, and then change the size in CyU3PDmaChannelConfig_t. And now I can send a vendor request through control endpoint 0x00 to do this. But I have to preset several diffierent size like 256, 512,1024 in the firmware, and use diffierent request codes to choose the exact size I want.

So, base on my solution, the buffer size can not be modified to a size that I didn't preset in the firmware. Is there any better way to modify the buffer size?

Thank you,

Fan

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Fan,

"If I want to send the information through GPIF II, what I should do? Do I need to set a bulk out endpoint and send the information to FPGA through DMA channel?"
>> Yes, but make sure the FPGA is notified to read the data when its available.

"How to modify the buffer size to be same as the data? "
>> When you request data of a specified amount from the device, you can send the length required as one of the values in the data.

When buffer size has to be modified, destroy the current DMA channel, change the buffer size in CyU3PDmaChannelConfig_t with the value sent from the host and then create the DMA channel again. 

There is no need to preset DMA buffer size. What I am trying to say is, you can declare the CyU3PDmaChannelConfig_t as global, and preset all other parameters of the structure except the size. Whenever a request comes from the host for a certain bytes of data, set the size to that value and create the channel with setXfer. Make sure to destroy the current DMA channel, when a new request from host comes. 

I would recommend you to try out the first method first. As the second may results in timing issues.

Best Regards,
AliAsgar

 

0 Likes

I got it. Thank you very much for your help

0 Likes