Problem with STM32H747 HS USB DMA.
Hello together,
after a lot of trouble getting the USB HS port working on the STM32H747 on the STM32H747I-DISCO Discovery kit I’m stuck again. I’m using STM Cube IDE 1.7 and the HAL USB CDC lib.
I was able to get USB CDC working on the M4 thanks to https://community.st.com/s/question/0D53W000002diUsSAI/stm32cubemx-h7x5h7x7-usb-cdc-bug
On the M7 core it kind of worked out of the box. But when I want to use it with the USB interal DMA enabled it didn’t work at all.
I already figured out I have to disable the D-cache and not use the DTCM SRAM for the buffer: https://community.st.com/s/article/how-to-enable-dma-in-usb-with-stm32h7-devices
I provided a minimal example of code which already results in failure:
...
MX_GPIO_Init();
MX_USB_DEVICE_Init();
HAL_Delay(1000);
uint8_t buffer1[2000], buffer2[2000];
CDC_Transmit_HS(buffer1, 1468);
HAL_Delay(50);
CDC_Transmit_HS(buffer2, 4);
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}When I use CDC_Transmit_HS() it works. I can send data from the provided buffer. I can also do this multiple times. And the DMA seems to work, as the execution time of CDC_Transmit_HS() is rather short and independent of the buffer length.
BUT: I can only send 1468 bytes of data. If I use a buffer length > 1468 bytes it doesn’t send anything.
If I send say CDC_Transmit_HS(buffer1, 1460) and than CDC_Transmit_HS(buffer1, 12) I get the first 1460 bytes transferred but the second call is not transmitted.
I also tried different memory addresses for the buffer pointer. E.g. 0x30020000 (SRAM2).
Always the same.
After the CDC_Transmit_HS() the CPU is normally executing code, just without any data being sent.
Any idea what I am doing wrong? With internal IP DMA disabled it works fine with large buffers and repeatably.
Thanks a lot
