DMA SPI Transfer with Stall Between Words

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

cross mob
JuCh_3556216
Level 1
Level 1
5 replies posted 5 questions asked First reply posted

Hi everyone,

I'm trying to figure out what the best method for configuring an FX3 would be in order to achieve this SPI transaction. Each SPI transaction must have an adjustable "stall time" appended after being transmitted on the order of microseconds. The entire block of SPI data to be transmitted (four 16-bit words in the attached example) must only be transmitted after receiving a "data valid" pulse on a gpio. I have successfully implemented the SPI transactions using CyU3PSpiTransmitWords() and CyU3PSpiTransferWords() and am successfully storing data in a pre-allocated buffer, but I have not been able to figure out what the best method would be to send the data to the PC over USB. I've included a few captures of what I'm looking to do, as well as what my issue is:

pastedImage_8.png

Above Image: Desired SPI sequence

pastedImage_9.png

Above image: Desired SPI sequence illustrating stall time

pastedImage_10.png

Above image: SPI transactions become inconsistent after filling the transmit buffer and sending to the PC over USB

Thanks!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

Please find the attached project which is a modification of cyfxusbspidmamode SDK example.

In this,an IN Endpoint: 1 is added and the data received from SPI is  sent to EP1 instead of EP0.

The EP0 would just be performing a zero length transfer.

Regards,

Hemanth

Hemanth

View solution in original post

0 Likes
5 Replies
JuCh_3556216
Level 1
Level 1
5 replies posted 5 questions asked First reply posted

Hi,

I wanted to see if anyone had some input on how to achieve this. I've tried sending data using a manual dma transfer after each cycle, but USB latency seems to be an issue using that method.

0 Likes

I've been trying out a few more things and think I may be on the right track. If I set up a DMA where the CPU is acting as the producer and the USB as a consumer, then I think I may be able to write data to the buffer as data packets become available and shove them out to USB without any CPU invervention (for that part of the transfer, anyway). Does this sound like something that would work?

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

Don't you want to use Endpoint 0 for the data transfer over USB to Host?

If you refer to the following example, the data read from the Flash over SPI is sent to USB over Endpoint 0:

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

Regards,

Hemanth

Hemanth
0 Likes

I don't want to use endpoint 0 since I'm using that for application control. This data stream is unique in that both timing and reacting to an external GPIO are both critical.

0 Likes
lock attach
Attachments are accessible only for community members.
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

Please find the attached project which is a modification of cyfxusbspidmamode SDK example.

In this,an IN Endpoint: 1 is added and the data received from SPI is  sent to EP1 instead of EP0.

The EP0 would just be performing a zero length transfer.

Regards,

Hemanth

Hemanth
0 Likes