Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I have read through all the DMA notes and USB datasheet and I am just a little confused conceptually on the best way to steam ADC data over USB. I am using the EOC on a Sequencing ADC to trigger a DMA channel from the final array of the ADC to the a ping pong buffer, and I would like to stream the data over USB. Using DMA with manual buffer management this is pretty straightforward: Each TD triggers an interrupt and the ISR sends the inactive (full) buffer to the USB using loadInEP().
I was thinking it would be better to use USB DMA with automatic buffer management since it would enable the use of a larger buffer for each loadEP (it is an ISO endpoint), but since the source array changes each time I need to call load it seems like I would have to call loadEP twice? the first time sets the new source array and the second time triggers the DMA? this is more complicated than the manual DMA it seems for this kind of setup.
If I set up DMA directly from the ADC results buffer (two bytes, since I am sequencing two channels at 8-bits each) to the USB ISO endpoint would it buffer them and send a full packet at once or would it just send a ton of two-byte packets?
I have been reading that appnote and playing with the examples, and have read that thread. What I still don't understand is what triggers the DMA transfer in automatic mode. Is it just a call to USBFS_LoadInEP, with NULL in the second parameter? what is the advantage of that over just calling it with a buffer in the second parameters? It doesn't seem very automatic if i have to poll USBFS_GetEPState like in the example and then manually call LoadInEP when it is ready. Especially if I am streaming data from an ADC then I will probably have two buffers in a ping-pong setup so I can't just rely on the pointer passed in the first call to LoadInEP (?)
Basically the DMA with Automatic memory management is suitable for the data transfer in which the buffer is not changing regularly. However you can also use it when buffer is changing to, but just note that it will take some extra time for configuring the DMA for the new source address.You can offload CPU from the data transfer activity.