Thank you very much for the example!
However, the TRM and the appnotes state that Auto-DMA should be only used for Isochronous EPs while for Bulk/Interrupt EPs Manual-DMA should be used. Or are there still any benefits to use Auto-DMA with Bulk?
Unfortunately I did not find any examples for Manual-DMA.
It can be used for any endpoint, but I think it was mainly developed for Isochronous endpoints. The USBFS buffer size is 512 bytes, so if you use the Manual Mode, you will not be able to store a data packet of size >512 bytes, although the data packet for Isochronous Transfers can carry upto 1023 bytes in case of Full-speed.
The DMA with Automatic Memory management allows you to use this full capability of Isochronous.
Besides, it can be very well used for Bulk/ Isochronous / Interrupt endpoint. Using third mode actually increases the data throughput.
Regarding your query on Manual DMA operation code example. I did make one and added to the forum. I'll check and add here again.
You can also reference AN56377 which contains an example project for USBFS with Auto DMA.
Thanks a lot for the example project. I am new to PSoC and have limited understanding of DMA operation. I found your example code very useful to understand DMA Auto-mode transfer.
However, I have following questions if you can please explain them for everybody's benefit:
1. Consider the OUT_EP and the single buffer (BufferOut) in the example code. Within the 'for(; ;)' loop, the DMA is configured only for the first time, and DMA transfer is initiated between the OUT_EP and the local buffer (BufferOut) followed by enabling of OUT_EP (USBFS_EnableOutEP(OUT_EP)) (line 55-57). In subsequent loops, if the OUT_EP state is full (USBFS_OUT_BUFFER_FULL), then, only the OUT_EP is enabled again without invoking USBFS_ReadOutEP call becuase the buffer is the same (line 63-69). My doubt is: How is it ensured in the program that the previous DMA transfer is finished before the new DMA transfer is initiated? For example, suppose that during one loop, the program finds the OUT_EP state to be full and initiates DMA transfer, followed by enabling of OUT_EP ((line 63-69). The program then immediately goes for the next loop and again checks the OUT_EP state. If the previous DMA transfer is not over, it may again find the OUT_EP state to be full and start the the DMA transfer again to the same buffer. Shouldn't the program initiate the next DMA transfer only after ensuring that the previous DMA transfer is over? Does the call USBFS_EnableOutEP(OUT_EP) ensures that the previous DMA transfer is over before enabling the OUT_EP?
Similarly, in case of IN_EP, if the IN_EP is empty, the DMA transfer is initiated by passing the NULL pointer to USBFS_LoadInEP() call. How is it ensured by the program that the local buffer has new data to be transferred? What if the local buffer has no data to transfer? (For example, suppose the PSoC receives bursty data over its GPIO pins and the firmware stores this data into the local buffer. The buffer is filled only when the burst arrives. Once the buffer is full, then only the firmware should initiate DMA transfer. How does the example program handle such situation?)
2. In DMA Auto memory mangement mode, does the program starts transfering the data from OUT_EP buffer to the local buffer only after OUT_EP buffer is full, or as soon as the data starts arriving in the OUT_EP buffer from the application (cut-through mode)? If the second case is true, then does it mean that (at least for Auto DMA mode) USBFS_OUT_BUFFER_FULL state implies that the OUT_EP buffer has some data and is not empty?
3. From the fireware developer's prospective, how is manual DMA mode different from Auto DMA mode? The application note says that in auto mode, the EP buffer memory is to be managed by the developer himself. What does that exactly mean? Do we have access to EP buffer memory in our firmware code? Is there any Manual DMA mode example code which you can post to help us all?