FX3 Bulkin Application C++ reference and example

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

cross mob
EsPo_3827446
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

I want to develop C++ application for fx3 bulk transfer IN?

where I need to refer? 

How much data (maximum data) can able to transfer in fx3 in sec? Is any calculation for this?

I want to receive 7,40,54,400 bits from FPGA through FX3.

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

Hello,

You can refer to the streamer application that comes along with FX3 SDK. The project can be found in the following path after downloading the FX3 SDK:
C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer

The project is developed by making use of CyAPI.lib. CyAPI.lib provides a simple, powerful C++ programming interface to USB devices. More specifically, it is a C++ class library that provides a high-level programming interface to the CyUsb3.sys device driver. The library is only able to communicate with USB devices that are served by (i.e. bound to) this driver.

Please refer to the document CyAPI.pdf to obtain more information on CyAPI.lib. It can be found in the following location of FX3 SDK:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\SuiteUSB

When you say "I want to receive 7,40,54,400 bits from FPGA through FX3.", I hope that FX3 is connected to the FPGA over GPIF II interface. The maximum width of data bus for GPIF II interface is 32 bits and maximum supported clock frequency is 100MHz. So, the maximum supported data rate will be 3.2Gbps for this application (if the data bus width is 32 bits and the interface clock is 100MHz).

Best Regards,
Jayakrishna

View solution in original post

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

Hello,

You can refer to the streamer application that comes along with FX3 SDK. The project can be found in the following path after downloading the FX3 SDK:
C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer

The project is developed by making use of CyAPI.lib. CyAPI.lib provides a simple, powerful C++ programming interface to USB devices. More specifically, it is a C++ class library that provides a high-level programming interface to the CyUsb3.sys device driver. The library is only able to communicate with USB devices that are served by (i.e. bound to) this driver.

Please refer to the document CyAPI.pdf to obtain more information on CyAPI.lib. It can be found in the following location of FX3 SDK:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\SuiteUSB

When you say "I want to receive 7,40,54,400 bits from FPGA through FX3.", I hope that FX3 is connected to the FPGA over GPIF II interface. The maximum width of data bus for GPIF II interface is 32 bits and maximum supported clock frequency is 100MHz. So, the maximum supported data rate will be 3.2Gbps for this application (if the data bus width is 32 bits and the interface clock is 100MHz).

Best Regards,
Jayakrishna
0 Likes

Hi JayaKrishna,

 I referred Streamer application project. I am using visual studio 2019 and SDK 8.1 after including CyAPI.lib, I having below error.  

EsPo_3827446_0-1634207301655.png

Thanks & Regards

Esakki

 

0 Likes

Hello Esakki,

Is this error seen in the streamer application itself or are you trying to build your own project?

Best Regards,
Jayakrishna
0 Likes

Hi JayaKrishna,

Yes, above error was occurred  during the  build/compiling  the streamer application project. 

First I try to execute the streamer application. 

Please help this. 

Thanks & Regards 

Esakki

 

 

0 Likes

Hello Esakki,

We do not see the error (MSB8003) at our end. It could be related to the installation of Visual Studio in your PC. We are using the following configurations for building the project at our end:

JayakrishnaT_76_0-1634611695840.png

Please try with the above settings and let me know if you face any issues.

The LNK2001 can occur if the project is missing a reference to the .lib file. Please confirm that you have added the CyAPI.lib as linker input in the development environment. You can refer to the following link to understand how to do this:

https://docs.microsoft.com/en-us/cpp/build/reference/dot-lib-files-as-linker-input?view=msvc-160

CyAPI.lib can be found in the following location:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\library\cpp\lib\x64

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

I tried with the above setting and I added  CYAPI.lib as linker input in the development environment.  

EsPo_3827446_2-1634709826037.png

 

 

EsPo_3827446_0-1634709522742.png

EsPo_3827446_1-1634709549681.png

and also I tried with Other PC which have visual studio 

still I have the same error.

EsPo_3827446_3-1634709913174.png

Moreover I referred below link also and I tried this also. 

https://community.cypress.com/t5/Knowledge-Base-Articles/CyAPI-lib-CyAPI-obj-Error-LNK2019-Unresolve...  

Please Help this !!!

Thanks & Regards

Esakki 

 

 

 

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Esakki,

Please revert the Streamer Application to the default state. After this, follow the steps given below:

1. Use the configuration settings that were shared in my previous response.

2. In the Linker settings, Under General Settings, please do not add any Additional Library Directories.

3. In the Linker settings, Under Input Settings, add the following in Additional Dependencies:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\library\cpp\lib\x86\CyAPI.lib
setupapi.lib
legacy_stdio_definitions.lib

With these settings, I was not able to see any build errors. I was able to build the project successfully. I am attaching the project that was built at my end successfully along with this response.

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna 

I download the shared  streamer project, as per your suggestion I did 

1.  I configured the setting 

2. In linker setting, under general setting I didn't add any directories .

EsPo_3827446_1-1634790223289.png

3. In linker setting, Under input , in additional dependencies I added below 

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\library\cpp\lib\x86\CyAPI.lib
setupapi.lib
legacy_stdio_definitions.lib

 

 

EsPo_3827446_0-1634790024737.png

Still I have below error. 

EsPo_3827446_2-1634790365125.png

 

Thanks & Regards

Esakki

 

0 Likes

Hi Jayakrishna,

I referred streamer application developed in C#.  I compiled its successfully and I execute the application. I connect hardware it have FPGA and FX3(EVM). I gave test case input to hardware and I able to receive the data in PC . 

 Here I want to know :

[1] how much data are receiving in sec.  

[2] I want  to know  the receiving  raw data in variable  in Streamer application C# / C++ project.  with reference these  I want to receive 3.2Gbps for my application development. 

 

EsPo_3827446_0-1634897637741.png

EsPo_3827446_1-1634897697795.png

 

In above figure: C# streamer application. here  How throughput is 100KBys?

Why Packet per Xfer? and Xfer to Queue? How to calculate for  3.2Gbps?

Is any test case available for Streamer application? because we are using fx3 with 100MHz?  

 

In below Figure May I know why throughput(100Kbps)?

EsPo_3827446_1-1634899027644.png

 

 

Thanks & Regards 

Esakki

 

 

 

0 Likes

Hello Esakki,

Please find my comments to your questions below:

[1] how much data are receiving in sec.  

>> Streamer application will calculate the data rate and displays it as it captures/sends data from/to the device.

[2] I want  to know  the receiving  raw data in variable  in Streamer application C# / C++ project.  with reference these  I want to receive 3.2Gps for my application development. 

>> You can modify the streamer application to log the received data. The C++ Streamer application has an option to display the received data. But, this will affect the performance. So, it is not recommended as your application makes use of a data rate of 3.2 gbps.

For understanding about the settings of streamer application, you can refer to the page 4 of the following document:

https://www.cypress.com/file/125281/download

You need to set the packets per xfer and xfers to queue in such a way that the device always receives IN tokens so that the host can read the data from the endpoint.

Here, the data rate is displayed as 100KBps. This can be due to multiple reasons. Please ensure that you have set burst to 16. Also, the size of DMA buffer used should also be large. The document found in the link shared above contains details on the performance of bulk, interrupt and isochronous endpoints of FX3 using streamer application. 

Best Regards,
Jayakrishna
0 Likes

Hello Esakki,

Please try building the project that was shared in my previous response. As mentioned before, this project builds successfully at our end without any errors. If the problem persists with the project that was shared in my previous response, then I think it is a problem related to your host PC/visual studio installation. Please cross check with a different PC.

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

I am sure I will try with different PC.  here I want to know  few details. Now I am using FX3 with 100MHz, so I want to receive 3.2Gbps and  here streamer application I noted throughput  it showing 100Kbps. Here why?  what I need to do for receiving 3.2Gbps? 

Thanks & Regards 

Esakki

0 Likes

Hello Esakki,

Please refer to the document in the link shared in my previous response to understand how the data rate can be increased. Another possibility is that FX3 may not be receiving data properly from the FPGA.

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

Can you share the required Visual studio version and SDK  details?  I will try with other PC? 

Here, I am using Community version.  

Thanks & Regards

Esakki

0 Likes

Hello Esakki,

I am using Visual Studio 2019 Community version. Windows SDK version is 10.0.19041.0. Please check if you have also downloaded all the required tools for development with C++ as shown below:

JayakrishnaT_76_0-1634901808263.png

 

Best Regards,
Jayakrishna
0 Likes

Hi Jayarkishna,

 Is Any testcase / test case example for FIFO / streamer  available? 

eg. (Test case )giving input  raw data to the hardware and it receiving the raw data in pc. 

Thanks & Regards 

Esakki 

0 Likes

Hello,

You can use the following example projects to test Streamer Application:

1. USBBulkSrcSink. This example project can be found in the following location of FX3 SDK:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxbulksrcsink

2. Gpiftousb. This example can be located in the following location of FX3 SDK:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

I have few doubts, In FX3 Firmware , What is the difference between Slavefifo and bulksrcsink??   Burst Length, DMA size?? 

[1] By using slavefifo is it possible to receive 3.2Gbps  from FX3,  because we interfacing FX3 with FPGA ?

[2] I tested cyfxbulksrcsink  example with streamer application?  so shall I use this ccyfxbulksrcsink as reference for  streaming by using fpga and fx3.  I found the test pattern values CY_FX_BULKSRCSINK_PATTERN (0xAA)  in ccyfxbulksrcsink.

 

[3] are any programming guide for Fx3 (slavefifo and bulksrcsink)?

 

Thanks & Regards 

Esakki 

 

 

 

0 Likes

Hello Esakki,

Please find my comments for your questions below:

1. Slave Fifo and USBBulkSrcSink are two different projects. The slave fifo project implements an interface (Slave Fifo interface) between an FPGA and FX3 for performing data transfer between these devices. The USBBulkSrcSink is an example project to demonstrate BULK IN and BULK OUT operations. It just enumerates with 2 endpoints. The data received from OUT endpoint will be discarded within the device. A test pattern is sent out through the IN endpoint. So, both these projects are different in terms of functionality. The burst and DMA buffer sizes can be configured based on your requirement. To increase the data rate, we recommend you to use a burst of 16 and large DMA buffers.

2. The Slave fifo interface makes use of DMA flags to check if there is space available in FX3's P Port buffers to write data or if there is data available in FX3's P Port Buffers to read data. The flag status is used by the master (FPGA) to perform the data transfers. Once the flag status changes to full (for write operation) or empty (for read operation), FPGA cannot initiate a write or read operation. Also, it takes some time for the flags to come back to the active state again after they show this full/empty status. More details on flags, slave fifo interface and data transfers is already documented in the following application note:

https://www.cypress.com/file/136056/download

Also, the data rate obtained using the streamer application with Slave Fifo project is shown in Section 11.5.2 of the application note mentioned above.

3. As mentioned before in this response, the USBBulkSrcSink is a project developed to demonstrate the bulk IN and bulk OUT operations only. It does not configure the GPIF II block for interfacing FX3 with an external device like FPGA. It just performs the following tasks:

a. Accepts data sent from the host through Bulk OUT endpoint and discards it.

b. Sends test pattern (generated by CPU) through Bulk IN endpoint to host.

We recommend you to use Slave Fifo interface itself for establishing the interface between FX3 and FPGA.

4. FX3 SDK comes along with a rich documentation. You can refer to the following location inside the SDK for all these documents:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\firmware

The above path inside the SDK contains all the documents such as TRM, Programmers Manual, Troubleshooting Guide etc. which can be used over the course of development.

Best Regards,
Jayakrishna
0 Likes

Hi Jayarishna,

Regarding  Burst length and DMA Buffer, May  I know in which location  I have to look in slavefifo.

I noticed in cyfxslfifousbdscr.c  

under /* Standard super speed configuration descriptor */

/* Super speed endpoint companion descriptor for producer EP */

0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type */
0x00, /* Max no. of packets in a burst : 0: burst 1 packet at a time */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00, /* Service interval for the EP : 0 for bulk */

 

/* Super speed endpoint companion descriptor for consumer EP */
0x06, /* Descriptor size */
CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type */
0x00, /* Max no. of packets in a burst : 0: burst 1 packet at a time */
0x00, /* Max streams for bulk EP = 0 (No streams) */
0x00,0x00 /* Service interval for the EP : 0 for bulk */

 

Thanks & Regards

Esakki

 

0 Likes

Hello Esakki,

Firstly, please use the Slave Fifo project that comes along with AN65974.zip which can be downloaded from the following link:

https://www.cypress.com/documentation/application-notes/an65974-designing-ez-usb-fx3-slave-fifo-inte...

For changing the burst setting, you need to modify the descriptors and the endpoint configuration settings in the cyfxslfifosync.c file. The snapshots of these are given below:

1. The burst setting in descriptors:

JayakrishnaT_76_0-1635401440091.png

JayakrishnaT_76_1-1635401452010.png

2. In the cyfxslfifosync.c file:

JayakrishnaT_76_2-1635401508480.png

The DMA buffer size can be by changing the size parameter in the following snapshot:

JayakrishnaT_76_3-1635401575369.png

The count parameter shows the number of such DMA buffers that should be allocated. Here, we use a P to U channel and U to P channel.

Please ensure that the total DMA buffer size allocated for the entire application is less than the maximum available DMA buffer size (around 220KB with the default memory map for 512KB SRAM). Otherwise, the DMA channel creation will fail with error "CY_U3P_ERROR_MEMORY_ERROR".

Best Regards,
Jayakrishna
0 Likes

Hi JayaKrishna,

I tried with  1.The burst setting in descriptors:  and i changed burst length from 1 to 16.

below figure default burst length 1 and I noted in control center :

here I want know in details:

MaxPktSize =1024    , Its means?

If I used burst length as 1 , why Maxpkt Size is 1024, and what is maximum throughputs/datarate?

 

EsPo_3827446_0-1635488380028.png

 

If I used burst length as 16, I noted in control center MaxPktSize is 16384 , Please see the below figure.  

If I used burst length as 16, MaxPktSixe is 16384, May I know is I am able get 3.2Gbps or what is the maximum throughputs /datarate?

EsPo_3827446_1-1635488739901.png

Thanks & Regards

Esakki

 

 

 

0 Likes

Hello Esakki,

The bandwidth or data rate here also depends on the rate at which FX3 receives data from FPGA. As mentioned before, FX3 is a slave and FPGA is the master. Even though the interface clock is 100MHz and the data bus width is 32 bits, the data rate need not be 3.2Gbps. This is because FPGA relies on the flag status to drive or sample data into the GPIF II block of FX3. So, the rate at which the data is received by FX3 will be less than 3.2Gbps.

Also, the max packet size is found by multiplying the packet size setting with the burst setting.

Please refer to the Table 5 of the following document to understand the throughput obtained by using streamer application when different burst, buffer size and number of buffers were used:

https://www.cypress.com/file/125281/download

As I mentioned earlier in this response, the data rate depends on the rate at which data is received by FX3 too. So, the maximum data rate will be less than 3.2Gbps for your application. But you can vary the settings in streamer application based on Table 5 to receive the data from FX3.

Also, the data rate obtained using the streamer application with Slave Fifo project is shown in Section 11.5.2 of the application note mentioned below:

https://www.cypress.com/file/136056/download

Best Regards,
Jayakrishna
0 Likes