ADC -> USBFS (bulk) highest throughput | Cypress Semiconductor
ADC -> USBFS (bulk) highest throughput
I am working on a project for which I just need to read 4 SAR ADC channels as quickly as possible while streaming the data back to a PC using bulk transfers with USBFS.
The problem I keep running into is that the maximum sampling frequency seems to be limited to ~30 kSPS per channel - for a total of 120 kSPS on all four channels. Whenever I try to go beyond that, my device is either dropping packets (IRQ controlled) or crashes the USBFS (DMA controlled). So I suspect I am probably missing something. The two strategies I have tried so far are outlined below:
1. IRQ based - Here, I use the conversion complete interrupt to write values and set a data-ready flag. I am polling in the main loop and every time a new sample is there, I initiate a DMA transfer to the USBFS component. This is working robustly, but breaks down at sample rates > 30 kSPS per channel (120 kSPS total). It seems like retrieving the values from the ADC final buffers can't happen fast enough - when fetching data is commented out, throughput on the USB bus goes up to >800 kB/s.
2. DMA based - In this case I tried to circumvent the data fetching problem by setting up DMA transfers triggers by the eoc signal. Here, 8 bytes (4 channels) get transferred to a buffer (64 bytes) upon end of each conversion. When 64 bytes are transferred this way, an IRQ is used to initiate another DMA transfer from the buffer to the USBFS component. This also works fine at lower conversion speeds, but upwards of ~30 kSPS, the PSoC seems to crash after a few seconds and there is no more USB data coming in to the PC.
What am I missing here? Is there another strategy people typically use to obtain the highest throughput for streaming ADC data via USBFS?
Any help or hints are appreciated!