cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure USB host MSC with CubeMX?

flor.5506
Associate II

Hello,

I use the STM32F767ZI card and I want to use USB OTG host communication.

For that I tested the program provided by STM32CubeMX, "FatFs_USBDisk". The program worked well.

But when I tried to redo the program using CubeMX. The program compiled. I started the program in debugger mode but couldn't create the file on the USB drive.

Is there a reason that the program generate with CubeMX doesn’t work?

I’m using STM32CubeMX v5 with package STM32Cube_FW_F7_V1.14.0.

Parameter of CubeMX:

RCC ->          HSE : BYPASS Clock Souce

                      LES : Crystal /Ceramic Resonator

SYS ->           Serial Wire

                      Timebase Source : SysTick

Sysclk :          168MHz

USB :            48MHz

USART3 ->   Asynchronous

USB_OTG_FS ->     Host_Only

                                  Activate_SOF

                                  Activate_VBUS

USB_HOST ->          Class for FS IP : Mass Storage Host Class

FATFS ->      USB Disk

3 REPLIES 3
Mon2
Senior III

Review the following thread (also comments on the posted code) on how to do the same with STMF4 which should be similar:

https://community.st.com/s/question/0D50X00009Xkdq2SAB/usb-disk-with-cubemx-and-stm32f4discovery

and the referenced blog.

flor.5506
Associate II

Thank you for your reply.

I read the comments and blog and modified my program. But the program still doesn’t work.

The problem comes from the interrupt settings. The program doesn’t go into the "OTG_FS_IRQHandler" function. This function will say that a USB key is connected.

Moreover, I never go into the functions found in the file "usbh_msc.c".

I changed the level of priority to have the same level as in the example provided by CubeMX but it didn’t change anything. (Command changed: HAL_NVIC_SetPriority (OTG_FS_IRQn, 6, 0)).

Do you have an idea to solve the problem?

flor.5506
Associate II

Finally, the problem was solved on its own. I don't know where the problem came from, but following the tutorial provided for STMF4, the program works.

However, I didn't follow the tutorial because I left the heap size at 0x200 and the stack size at 0x400.