0

STM32F723 USB_CDC with DMA problems

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.

Snipped form the CubeMX config

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.

CoObri
  • 13
  • 5
  • i'd try to debug the call chain, by setting breakpoints e.g. in the CDC_TransmitCplt_xxx function and have a look what's called befor that function. Somewhere in between there has to be some code, that handles the DMA, and there must be the reason why it's not resetting the buffer. – Chris_B May 16 '23 at 09:50
  • @Chris_B I did some debugging but I think the DMA is not even initialized.. I can't find some DMA init or any other DMA functionallity in the _usb_device_ / _usb_cdc_ / _usbd_desc_ files. For me It's not clear if I have to add stuff in the CubeMx so that DMA works. – CoObri May 16 '23 at 10:13
  • what does the CubeMX "DMA" page say? At least one DMA channel should have some sort of "connection" to the USB peripheral. Either directly or eventualy as "Mem to Mem"? I'd also digg through the CDC_Transmit and CDC_Receive functions, to find some calls to the DMA functions. If there are none, then I'd assume the code generation is wrong. Sometimes it helps to disable the peripheral with all it's components, clean project, generate code, and re-enable and re-configure it to make it work. I often have such issues with SPI, especially if there was a firmware update in between. – Chris_B May 16 '23 at 12:55

0 Answers0