AnsweredAssumed Answered

[STM32L4] Configure STM32L4 as USB Device Mass Storage

Question asked by bhayani.sunny on Jun 22, 2016
Latest reply on Jun 23, 2016 by bhayani.sunny
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

Outcomes