[usb3.0]How to use two producers in fx3

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

cross mob
lance2021
Level 1
Level 1
First like given 10 sign-ins 5 sign-ins

Hi, I'm having trouble again.I am using FX3's slavefifo program for bidirectional communication between FPGA and PC.It works very well,but we want to make a little improvement.Now consider such a transmission path:

FPGA->FX3->PC,

For fpga,we set[A1:A0]=00,and then the data is written.In cyfxslfifosync.h,the sample program has the following lines of code:

#define CY_FX_EP_PRODUCER 0x01 /* EP 1 OUT */
#define CY_FX_EP_CONSUMER 0x81 /* EP 1 IN */

#define CY_FX_PRODUCER_USB_SOCKET CY_U3P_UIB_SOCKET_PROD_1 /* USB Socket 1 is producer */
#define CY_FX_CONSUMER_USB_SOCKET CY_U3P_UIB_SOCKET_CONS_1 /* USB Socket 1 is consumer */

#define CY_FX_PRODUCER_PPORT_SOCKET CY_U3P_PIB_SOCKET_0 /* P-port Socket 0 is producer */
#define CY_FX_CONSUMER_PPORT_SOCKET CY_U3P_PIB_SOCKET_3 /* P-port Socket 3 is consumer */

So far everything is perfect.But we want to use two producers.For example, the FPGA first writes data (size=one dma buffer)to address 0, and then quickly switches to address 2 to continue writing(if address 2 is available), which can avoid bandwidth loss caused by DMA switching.Of course, FPGA will monitor the value of flag to avoid errors.The problem is, we don't know what parts of FX3 need to be modified.For example, how to define two producers of  P port?How two producers map to one consumer?(We don't care about the order of the data packets.)I'm very sorry, I didn't find the relevant information, I have to say that the design of FX3 is very different from FPGA and software.Please tell me how to do this. Thank you very much!

by the way ,we use auto DMA channel.

Sincere learner

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

The #defines that are mentioned in your description are for setting the parameters used by the API CyU3PDmaChannelCreate () and for configuring the endpoint using the API CyU3PSetEpConfig (). The API CyU3PDmaChannelCreate () is used for creating a DMA channel between a single producer and single consumer.

The #define CY_FX_EP_PRODUCER will be used for referring to OUT endpoint 1 and CY_FX_EP_CONSUMER will be used for referring to IN endpoint 1. As for the USB sockets (i.e CY_U3P_UIB_SOCKET_PROD_1 and CY_U3P_UIB_SOCKET_CONS_1), there is a direct mapping between the USB endpoints and the corresponding DMA sockets. That is, the socket CY_U3P_UIB_SOCKET_PROD_1 will be mapped to out endpoint 1 and CY_U3P_UIB_SOCKET_CONS_1 will be mapped to IN endpoint 1.

For the P-Port sockets, CY_U3P_PIB_SOCKET_0 will be mapped to socket 0 of P-Port. SImilarly,CY_U3P_PIB_SOCKET_3 will be mapped to socket 3 of P-Port. The API CyU3PGpifSocketConfigure () is used to map the active socket with a thread which is actually addressed by the FPGA.

Now, as you would like to create a DMA channel between multiple producers (2 producer socket) and one consumer socket, you should be using the API CyU3PDmaMultiChannelCreate (). You can use the source code of AN75779 as a reference to understand how to set the different parameters of this API. The source code of AN75779 can be downloaded by downloading the file AN75779.zip from the Application Notes section of the following link:

https://www.infineon.com/cms/en/product/universal-serial-bus-usb-power-delivery-controller/periphera...

You can modify the slave FIFO project by referring to the source code of AN75779. 

Please let me know if you have any queries on this.

Best Regards,
Jayakrishna

View solution in original post

0 Likes
4 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

The #defines that are mentioned in your description are for setting the parameters used by the API CyU3PDmaChannelCreate () and for configuring the endpoint using the API CyU3PSetEpConfig (). The API CyU3PDmaChannelCreate () is used for creating a DMA channel between a single producer and single consumer.

The #define CY_FX_EP_PRODUCER will be used for referring to OUT endpoint 1 and CY_FX_EP_CONSUMER will be used for referring to IN endpoint 1. As for the USB sockets (i.e CY_U3P_UIB_SOCKET_PROD_1 and CY_U3P_UIB_SOCKET_CONS_1), there is a direct mapping between the USB endpoints and the corresponding DMA sockets. That is, the socket CY_U3P_UIB_SOCKET_PROD_1 will be mapped to out endpoint 1 and CY_U3P_UIB_SOCKET_CONS_1 will be mapped to IN endpoint 1.

For the P-Port sockets, CY_U3P_PIB_SOCKET_0 will be mapped to socket 0 of P-Port. SImilarly,CY_U3P_PIB_SOCKET_3 will be mapped to socket 3 of P-Port. The API CyU3PGpifSocketConfigure () is used to map the active socket with a thread which is actually addressed by the FPGA.

Now, as you would like to create a DMA channel between multiple producers (2 producer socket) and one consumer socket, you should be using the API CyU3PDmaMultiChannelCreate (). You can use the source code of AN75779 as a reference to understand how to set the different parameters of this API. The source code of AN75779 can be downloaded by downloading the file AN75779.zip from the Application Notes section of the following link:

https://www.infineon.com/cms/en/product/universal-serial-bus-usb-power-delivery-controller/periphera...

You can modify the slave FIFO project by referring to the source code of AN75779. 

Please let me know if you have any queries on this.

Best Regards,
Jayakrishna
0 Likes
lock attach
Attachments are accessible only for community members.

Thank you for your answer! Sorry for the late reply, we took some detours and still got stuck. In short,When we tried to make some changes on the basis of SLAVE FIFO to define a many-to-one channel, but unfortunately, the compiler reported  errors, we thought it was because of some missing header files, but we didn't find it. It would be greatly appreciated if you could tell me how to deal with it.

0 Likes

I fixed it for now, thanks, if there are other questions, can I keep asking you in this question?

0 Likes

Hello,

We would recommend you to create new threads for other questions. This will help other community members in resolving their issues too.

Best Regards,
Jayakrishna