2023-05-15 09:54 AM
Hello,
I'm currently working on a project using the STM32F723 Discovery kit and USB as a Virtual Com Port (VCP) in CDC mode. I'm encountering an issue related to DMA and USB_OTG_HS when using the CubeMX configuration with the "Enable internal IP DMA" flag enabled.
The problem I'm facing is that when the "Enable internal IP DMA" flag is enabled in CubeMX, the application can echo the received data from the USB CDC RX buffer for only about three times. After that, it fails to send any data out over the CDC_OUT endpoint. Upon debugging, I found that the CDC_Transmit_HS function always returns USBD_BUSY, indicating that the transmission is still ongoing.
I have verified that without enabling the "Enable internal IP DMA" flag, the application works fine and can echo the received data without any issues. However, I would like to take advantage of DMA for better performance and efficiency.
Here are some additional details about my setup:
I suspect that there might be some additional configurations or considerations that need to be made when using DMA with USB_OTG_HS in VCP mode. I would greatly appreciate any insights or suggestions on how to resolve this issue and achieve proper DMA functionality with USB_OTG_HS.
Thank you in advance for your assistance.
2023-05-16 06:54 AM
Hi @CObri.1 , it is maybe due to USB PCD Fifo configuration
Please check this comment
/* TXn min size = 16 words. (n : Transmit FIFO index)
When a TxFIFO is not used, the Configuration should be as follows:
case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
--> Txm can use the space allocated for Txn.
case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
--> Txn should be configured with the minimum space of 16 words
The FIFO is used optimally when used TxFIFOs are allocated in the top
of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
2023-05-16 07:00 AM
Hello @mohamed.ayed,
thanks for taking time to answer to my question.
These configuration I'll find in the CubeMX or in which file do I have to check it?
Best regards
Corsin
2023-05-16 07:07 AM
Hi @CObri.1
You can find USB Fifo configutation in usbd_conf.c
You can see attached link as reference and customize your PCD FIFO in your application
Regards,
Mohamed
2023-05-23 04:41 AM - edited 2023-11-20 05:25 AM
Hi @mohamed.ayed,
I also posted the question (better explained) here:
https://stackoverflow.com/questions/76259908/stm32f723-usb-cdc-with-dma-problems
What I was wondering is, that I don't find any DMA functionality in the usbd_cdc source files.
Further if I check the CodeMX there is no peripheral connection possible for DMA <-> USB possible only M2M:
I can add a M2M like this:
But do I have to add this or should the DMA for USB be somehow autmatically included when enabling the IP DMA?
Best regards
Corsin
2023-05-23 06:15 AM - edited 2023-11-20 05:25 AM
Hi @CObri.1 , if you went to use internal USB DMA, you juste need to enable it in USB Configuration
Regards,
Mohamed
2023-05-23 06:20 AM
Hi @mohamed.ayed ,
Ok, yes I did that.
So the problem has to do with the FiFO Buffer you mentioned
above.
Have you tried a simple example with your setup?
Best regards,
Corsin