2025-11-28 5:54 AM - last edited on 2025-11-28 6:58 AM by Gyessine
Hi!
I have a problem.
I faced with a problem of USB middleware initialization as a virtual port in CubeMX. After code generation USB init initializes in main.c within of one of task FREERTOS. If I initialize USB only as connectivity USB init replaces right. How to resolve it?
Here details is:
/* USER CODE END Header_start_task_can_handler */
void start_task_can_handler(void *argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 5 */
app_start_task_can_handler(argument);
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END 5 */
}2025-11-28 6:12 AM
> If I initialize USB only as connectivity USB init replaces right.
What does this mean?
2025-11-28 6:21 AM - last edited on 2025-11-28 8:07 AM by mƎALLEm
Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.
Connectivity - > USB_OTG_HS -> Internal FS Phy -> Device only
Middleware and software ->USB_Device -> Disable
In this case I get USB init in correct place within main.c:
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_FDCAN1_Init();
MX_USB_OTG_HS_PCD_Init();