H7 USB_OTG_HS Mass Storage with SD card — issues at higher SD clock frequency
Hello,
I’m working on a custom board based on the STM32H753IITx and I'm trying to access a microSD card via USB_OTG_HS using the USB Mass Storage Class (MSC). I've read this post, which is close to my use case, but unfortunately, I haven’t been able to solve my issue.
Here is a summary of my configuration in STM32CubeMX:
SDMMC1 (SD card interface):
- Mode: SD 4-bit wide bus
- Clock transition: Rising edge
- Clock output when idle: Enabled (Power save disabled)
- Hardware flow control: Disabled
- Clock divide factor: 1 (which results in 200 MHz / (2 × 1) = 100 MHz SDMMC_CK)
- External transceiver: Not present
- All GPIOs maximum output speed to Very High
- All GPIOs except SDMMC1_CK have pull-up
USB_OTG_HS (Mass Storage Device):
- PHY: External PHY (ULPI), Device_Only
- Speed: High Speed (480 Mbit/s)
- IP DMA: Disabled
- Power management features: All disabled
- VBUS sensing: Disabled
- USB Class: Mass Storage Class
- MSC_MEDIA_PACKET size: 512 bytes
- USBD_SELF_POWERED: Enabled
- LPM (Link Power Management): Enabled
- All GPIOs maximum output speed to Very High
Here’s what I’m observing:
- When the SDMMC1 clock is set to 100 MHz, my PC detects the USB device, but fails to read from the SD card.
- When I reduce the clock to 25 MHz, the PC detects the card and I can read/write successfully.
- On the MCU side, FatFS works fine at both 25 MHz and 100 MHz for standalone read/write.
- When I try to initialize the SD card (via BSP_SD_Init) in the USB cable detection interrupt, the CPU freezes, SysTick stops, and the system gets stuck in an infinite timeout loop using HAL_GetTick().
- Even at low clock speeds, SD DMA read/write doesn't work when triggered from the USB MSC.
I'm using:
STM32CubeFW_H7 v1.12.1
STM32 USB Device Library v1.17.0
I've created a minimal standalone project reproducing the issue — it’s available here: https://github.com/Brandon-Altaneos/STM32H7_SD_USB_StandAlone/tree/master/SD_USB_Stand_Alone .
Any guidance or suggestions would be greatly appreciated.
Thanks in advance,
Brandon
