USB CDC device conflict with other peripheral
Hello,
I am working on the STM32H7A3ZGT6 with the following parameters
- CubeIDE 1.13.0
- CubeMX 6.9.0
I am trying to add a USB device CDC for debugging. My objective is to print debug data on the virtual port com. I am sucessufull at sending data directly after the USB CDC init but when I use another module, the USB isn't working anymore and the TX function if returning a Busy error
I configured the USB with the following parameters: (Clock to USB = 48MHz)


The USB is initialized fine and I can open the Port Com on my computer.
If I put data to the usb directly after the USB init it is working, but once I use another peripheral (UART, SPI…) the USB no longer outputs any data and the function CDC_Transmit_HS returns a busy error
MX_OCTOSPI2_Init();
MX_USB_DEVICE_Init(); // INIT USB OK
/* USER CODE BEGIN 2 */
HAL_Delay(5000);
uint8_t test_cdc_usb[] = "Coucou";
print_debug_usb(test_cdc_usb, sizeof(test_cdc_usb)); // PUT USB DATA OK
print_debug_usb(test_cdc_usb, sizeof(test_cdc_usb)); // PUT USB DATA OK
/*Memory*/
memory_SPI_Init(); // USES OCTOSPI2
memoryMes_init(); // USES OCTOSPI2
print_debug_usb(test_cdc_usb, sizeof(test_cdc_usb)); // PUT USB DATA ERROR BUSY
The Function used to flush data to the USB CDC is the following:
uint8_t usb_cdc_debug_buffer[2048];
void print_debug_usb(uint8_t * data, uint16_t size)
{
memcpy(usb_cdc_debug_buffer, data, size);
usb_cdc_debug_buffer[size] = '\n';
while(CDC_Transmit_HS(usb_cdc_debug_buffer, (size+1)) == USBD_BUSY);
HAL_Delay(300);
}
I didn't change the code genereated by CubeMX for the USB device and am using the CDC_Transmit_HS found in the usbd_cdc_if.h file.
Do you have any idea where this could come from?
thank you
Augustin
