Skip to main content
Associate
November 28, 2025
Question

STM32H723 problem with USB middleware initialization when FREERTOS is used

  • November 28, 2025
  • 1 reply
  • 146 views

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

}

1 reply

TDK
Super User
November 28, 2025

> If I initialize USB only as connectivity USB init replaces right.

What does this mean?

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate
November 28, 2025

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();