Skip to main content
Graduate
May 15, 2023
Question

STM32F723 Problem USB with DMA in VCP Mode

  • May 15, 2023
  • 3 replies
  • 2802 views

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:

  • STM32F723 Discovery kit
    • CubeMX configuration:USB_OTG_HS peripheral enabled with "Enable internal IP DMA" flag enabled
    • CDC class configured with appropriate endpoint sizes and buffer sizes
  • Using the STM32CubeF7 HAL library

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.

    This topic has been closed for replies.

    3 replies

    ST Employee
    May 16, 2023

    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 */

    CObri.1Author
    Graduate
    May 16, 2023

    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

    ST Employee
    May 16, 2023

    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

    https://github.com/STMicroelectronics/STM32CubeF7/blob/6eed5bb15304480bbd7cde7a30208d579fbde9dc/Projects/STM32F769I_EVAL/Applications/USB_Device/CDC_Standalone/Src/usbd_conf.c#L399

    Regards,

    Mohamed

    CObri.1Author
    Graduate
    May 23, 2023

    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:


    _legacyfs_online_stmicro_images_0693W00000bkfSIQAY.png I can add a M2M like this:


    _legacyfs_online_stmicro_images_0693W00000bkfWDQAY.png 

    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

    ST Employee
    May 23, 2023

    Hi @CObri.1​ , if you went to use internal USB DMA, you juste need to enable it in USB Configuration


    _legacyfs_online_stmicro_images_0693W00000bkgBVQAY.png 

    Regards,

    Mohamed

    CObri.1Author
    Graduate
    May 23, 2023

    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