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:
Above Image: Desired SPI sequence
Above image: Desired SPI sequence illustrating stall time
Above image: SPI transactions become inconsistent after filling the transmit buffer and sending to the PC over USB
Solved! Go to Solution.
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.
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?
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
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.