2024-04-16 01:11 PM
Hello,
I'm trying to communicate with the USB FS CDC on my NUCLEO-H723ZG while using FreeRTOS and the device doesn't enumerate properly. I am using the current up-to-date software pack for STM32H7 -> 1.11.2
I use the CubeMX starting project with the NUCLEO-H723ZG and I only add the USB_OTG_HS as a Full Speed Device.
Then I add the middleware for the CDC using all default parameters.
If I use the project at this point, the USB communication with the virtual comm port works flawlessly. However, it stops working when I add the middleware FreeRTOS with its default parameters
In Windows 11 Device Manager, I am getting the error were the USB descriptor failed (Code 43)
Is there a configuration I am missing ? I would have expected the USB CDC driver to work right out of the box with FreeRTOS at this point...
I have added the .ioc used to generate the projet as well as the main with the code to send an Hello_world message to the virtual com port. The only hardware required is the NUCLEO-H723ZG with 2 USB cables.
Solved! Go to Solution.
2024-04-17 02:19 AM - edited 2024-04-17 07:29 AM
Hello,
However, this function is never called since the code only runs the default task after starting FreeRTOS so I doubt it is the problem.
-> I agree.
Now testing your project and I've reproduced the issue. It seems there is a hardfault with your Task RTOS configuration.
The first thing to thing about in that situation (in baremetal is OK, with RTOS: Hardfault) is the Task stack size.
Increasing the stack size from 128 to 256 makes the hardfault disappears.
Hope it does answer your question.
2024-04-16 02:02 PM
Hello,
Why are you calling CDC_Transmit_HS() from a loop in main
while (1)
{
CDC_Transmit_HS(TxBuffer, strlen((const char *)TxBuffer));
HAL_Delay(1000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
and in StartDefaultTask() task ?:
void StartDefaultTask(void *argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
CDC_Transmit_HS(TxBuffer, strlen((const char *)TxBuffer));
osDelay(1000);
}
/* USER CODE END 5 */
}
2024-04-16 02:09 PM
Hello SofLit,
The CDC_Transmit_HS I called in the while(1) is a leftover function call when I first started the project without FreeRTOS to check functionality. My bad, I should have removed it when I added FreeRTOS in CubeMX. However, this function is never called since the code only runs the default task after starting FreeRTOS so I doubt it is the problem.
The call to CDC_Transmit_HS in the StartDefaultTask is used to display an "Hello World" every 1 second when I connect a serial terminal. Well if my code worked, that would have been the expected behavior...
Sorry for the confusion this leftover code caused, but I think the root cause of the problem is else where.
Thank you and have a nice day.
2024-04-17 02:19 AM - edited 2024-04-17 07:29 AM
Hello,
However, this function is never called since the code only runs the default task after starting FreeRTOS so I doubt it is the problem.
-> I agree.
Now testing your project and I've reproduced the issue. It seems there is a hardfault with your Task RTOS configuration.
The first thing to thing about in that situation (in baremetal is OK, with RTOS: Hardfault) is the Task stack size.
Increasing the stack size from 128 to 256 makes the hardfault disappears.
Hope it does answer your question.