cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32L4] Configure STM32L4 as USB Device Mass Storage

sunny
Associate II
Posted on June 22, 2016 at 12:51

Hi,

I have STM32L4 based board having USB OTG Connector.

I have microSD Card interfaced on SDIO (4-bit) and am using the FatFS by Chen from CubeMX.

I have used the code from CubeMX to configure the STM32L4 as USBD MSC.

I am able to get the USB enumerated on the PC when I connect the USB cable.

But I observed that if any write/open calls to Filesystem are ongoing when this enumeration of USB is happening, then the Filesystem operations are stuck.

After debugging, I found that when the USBD_Connect() is called, and the USB cable is already connected to the PC, the HAL_PCD_IRQHandler() is called multiple times.

It takes around ~2.914 seconds after which this HAL_PCD_IRQHandler() is not called and the USB is detected on the PC as Mass Storage.

So if I put a delay of 3 seconds after the USBD_Connect() call, then all the Filesystem related operations work fine.

So is there any other way by which I can avoid to put this delay of 3 seconds ?

Thanks,

Sunny

#stm32l4 #usbd #msc
1 REPLY 1
sunny
Associate II
Posted on June 23, 2016 at 05:58

Hi,

Can anybody please confirm the same and give a possible solution ?

Thanks,

Sunny