Skip to main content
Padma Kumari
Associate
January 12, 2023
Solved

Error when runing USB_OTG_FS with RTOS for pendrive application.

Hello Everyone,

First of all I have run the project with STM32H745I + USB_OTG_FS + FATFS + MSHC for the pendrive application and it runs without any error, I am able to create a file, directrory & write into the file.

But when I add FreeRTOS in the same combination of existing project I can only mount the USB after that I stuck in HardFault handler. I don't know what the exact setting I have to do with FreeRTOS.

If anyone have idea please help me out.

Thanks!

This topic has been closed for replies.
Padma Kumari
Padma KumariBest answer
Associate
January 20, 2023

Hello Everyone,

I have solved this problem, There were some settings to be done with FreeRTOS feature.

Missing settings were:

In USB_HOST_M7 Mode USBH_PROCESS_STACK_SIZE value should be 8*128 words with no check. USBH_PROCESS_PRIO value can be normal(default) or below normal. Another setting will be default.

In FATFAS_M7 setting set USE_LFN to Enable LFN with dynamic working buffer on the HEAP. USE_STRFUNC will be disabled.

For clock setting you can use the below parameters:

/* PLL3 for USB Clock */

 PeriphClkInitStruct.PLL3.PLL3M = 25;

 PeriphClkInitStruct.PLL3.PLL3N = 336;

 PeriphClkInitStruct.PLL3.PLL3FRACN = 0;

 PeriphClkInitStruct.PLL3.PLL3P = 2;

 PeriphClkInitStruct.PLL3.PLL3R = 2;

 PeriphClkInitStruct.PLL3.PLL3Q = 7; /* 336/7 =48Mhz*/

The timer on which FreeRTOS works Keep their priority at 4 and the priority of USB global interrupt is lower than 4 or can keep 15.

Thanks!

1 reply

Padma Kumari
Padma KumariAuthorBest answer
Associate
January 20, 2023

Hello Everyone,

I have solved this problem, There were some settings to be done with FreeRTOS feature.

Missing settings were:

In USB_HOST_M7 Mode USBH_PROCESS_STACK_SIZE value should be 8*128 words with no check. USBH_PROCESS_PRIO value can be normal(default) or below normal. Another setting will be default.

In FATFAS_M7 setting set USE_LFN to Enable LFN with dynamic working buffer on the HEAP. USE_STRFUNC will be disabled.

For clock setting you can use the below parameters:

/* PLL3 for USB Clock */

 PeriphClkInitStruct.PLL3.PLL3M = 25;

 PeriphClkInitStruct.PLL3.PLL3N = 336;

 PeriphClkInitStruct.PLL3.PLL3FRACN = 0;

 PeriphClkInitStruct.PLL3.PLL3P = 2;

 PeriphClkInitStruct.PLL3.PLL3R = 2;

 PeriphClkInitStruct.PLL3.PLL3Q = 7; /* 336/7 =48Mhz*/

The timer on which FreeRTOS works Keep their priority at 4 and the priority of USB global interrupt is lower than 4 or can keep 15.

Thanks!