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

USB superspeed peripherals Forum Discussions

Alex9142
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi,

The default GPIF_Example2 with Counter1.xsvf works great! I've tested at 40MHz and 80MHz, and it seems reliable.

Now I'd like to use an external GPIF clock instead of the internal one, but the USB transfer only works for roughly 0x10000 - 0x20000 bytes before stopping.

Steps to reproduce:

1) Edit GPIF_Example2.cyfx and switch the clock from Internal to External. Update SupplyDualGpifData.h in the GPIF_Example2 project and clean/build.

2) Load and run GPIF_Example2.img. Then connect a 5kHz clock to PCLK. (I'd like to support a wide range of clocks, up to 100MHz). The debug terminal "gpif" state changes to 1. If I allow the CPLD to run by typing "cpld", then the "gpif" state toggles between 2 and 3.

3) Try to run PC CollectData.exe for 10 seconds, but the output file is only a couple MB. Most data in CollectData.bin is a constant 0xefefefef, but some small sections have an incrementing 32-bit counter.

If I type "cpld" to start the state machine before running CollectData.exe, then the start of CollectData.bin has an incrementing counter for the first 0x10000-0x20000 bytes.

 

The final design won't use a CPLD, so I'd like to avoid any complex control circuitry outside the FX3. What's the best way to stream data like GPIF_Example2 but with an external clock?

 

Thank you.

0 Likes
1 Solution
Ajeethkumar
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 10 likes received

Hi Will,

Good to hear that your issue is resolved!

Please consider the following as a checklist whenever you are using DMA_WM_THx for streaming continuous data:
1. We have Buffer Area allocated for DMA buffer limited to 32kB by default. Please update the same based on your requirements in the FX3 firmware. Please also note that the Total DMA buffer size used in the project should be less than or equal to the above number.
2. Please configure the Watermark value using CyU3PGpifSocketConfigure() API. To know more about configuring the Watermark value, please refer to AN65974.
3. Set the Watermark value so that whenever DMA_WM_THx is asserted, at the next positive edge of the PCLK current DMA Buffer should be full so that the data will be Committed to USB. To know more about the General Formulae for using Watermark Partial Flags, refer to Section 9.3 of AN65974.

Note: In your GPIF II project, you can remove COUNT-related actions as they are not used anywhere in your project.

Thanks,
Ajeeth

View solution in original post

7 Replies
Ajeethkumar
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 10 likes received

Hi Will Lentz,

GPIF_Example2 in SuperSpeed Design Examples V1.2.1 is a fundamental example and does not have flow control.

In GPIF_Example2, even if the USB does not read the data it will overwrite the Pingpong buffers which results in data corruption in FX3. This could be the reason you see the later part of the Counter samples 0xefefefef if CollectData.exe is started after FX3 starts sampling the data.

You can look into the Gpiftousb example(C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb) for your application. Please give me more details on your application like Block diagram, use case, expected behavior of operation, etc. so that I can help you better in building your application.

Also, to use an external clock, you can choose external in GPIF II designer and no other changes are needed.

Thanks,
Ajeeth

0 Likes
Alex9142
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Thanks Ajeeth, I'll try that example soon. What PC program do you use with cyfxgpiftousb - Streamer.exe?

 

The basic block diagram is:

 - external clock (~1-100MHz) with 8-bit synchronous data -> FX3 GPIF input -> USB -> computer that logs continuous stream of data to an internal SSD.

The external 8-bit data is continuous and cannot be paused without losing data.

 

GPIF_Example2 with an internal PCLK seemed to stream 32-bit data at 40-80MHz data (~160-320MB/s) to my SSD without dropping any counts. It's only when I went to a really slow external PCLK (5kHz ~= 20KB/s) that the problems started. I'll also try a faster external PCLK, but it'd be good to know if there is a lower limit to the streaming speed. (e.g., do CollectData.exe or Streamer.exe have problems below a certain rate of data?)

 

 

0 Likes
Alex9142
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Thanks again Ajeeth. cyfxgpiftousb with an external PCLK of ~5MHz works with Streamer.exe and CollectData.exe.

However, every ~32KB it drops ~64 bytes. Is there an example that can take a continuous stream of data as described in my block diagram above?

 

Thanks, Will

0 Likes
Ajeethkumar
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 10 likes received

Hi,

Data loss is expected as there will be a delay of a few microseconds during every buffer switch using a Single GPIF thread.

I have updated the Gpif2USB project with two threads that can be used to avoid data loss. I am attaching the project here. Please test and let me know if you face any issues.

Thanks,
Ajeeth

Alex9142
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Ajeeth,

With your zipfile code there are lots of gaps. However, changing CY_FX_DMA_BUF_SIZE back to 16384 makes it _almost_ work. There is only a gap of 1 uint32 every 4096 bytes!


After some more searching, I found https://community.infineon.com/t5/USB-superspeed-peripherals/Master-GPIF2-read-errors/td-p/195007 which says to use DMA_WM_TH0 instead of DMA_RDY_TH0. The watermark works perfectly (at least up to ~160MB/s).


See the attached the GPIF state machine that works with the CPLD Counter, an external PCLK, and your code with the updated CY_FX_DMA_BUF_SIZE.


Thanks for all your help!!
Will

 

0 Likes
Ajeethkumar
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 10 likes received

Hi Will,

Good to hear that your issue is resolved!

Please consider the following as a checklist whenever you are using DMA_WM_THx for streaming continuous data:
1. We have Buffer Area allocated for DMA buffer limited to 32kB by default. Please update the same based on your requirements in the FX3 firmware. Please also note that the Total DMA buffer size used in the project should be less than or equal to the above number.
2. Please configure the Watermark value using CyU3PGpifSocketConfigure() API. To know more about configuring the Watermark value, please refer to AN65974.
3. Set the Watermark value so that whenever DMA_WM_THx is asserted, at the next positive edge of the PCLK current DMA Buffer should be full so that the data will be Committed to USB. To know more about the General Formulae for using Watermark Partial Flags, refer to Section 9.3 of AN65974.

Note: In your GPIF II project, you can remove COUNT-related actions as they are not used anywhere in your project.

Thanks,
Ajeeth

Alex9142
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Thanks again Ajeeth! I updated by DMA buffer size to 32KB and it still works well.

For a 32-bit bus the following worked:

CyU3PGpifSocketConfigure(0, CY_FX_GPIF_PRODUCER_SOCKET_0, 1, CyFalse, 0);
CyU3PGpifSocketConfigure(1, CY_FX_GPIF_PRODUCER_SOCKET_1, 1, CyFalse, 0);

 

For a 16-bit bus the same watermark worked, but I had to add a couple states to the GPIF state machine. After a watermark is hit, we need to read 1 uint16 to finish the buffer and then we can move to the next DMA thread.

0 Likes