STM32Cube  Version 2.1.0
Create Projects for STM32U5 Series with STM32Cube HAL and STM32CubeMX
MCI

Revision History

  • Version 1.0
    • Initial release

Instances

Hardware resource relating to driver instance is shown in the table below:

Driver Instance Hardware Resource
Driver_MCI0 SDMMC1
Driver_MCI1 SDMMC2

Configuration

STM32CubeMX

The MCI driver requires:

  • SDMMC1,2 peripheral clock
  • SDMMC peripheral mode configured
  • SDMMC_CK, SDMMC_CMD and SDMMC_Dx pins
  • SDMMC1 global interrupt enabled in NVIC
  • When using MMC devices:
    • Define MemoryCard_MMC0 if SDMMC1 uses MMC device (otherwise define is not required)
    • Define MemoryCard_MMC1 if SDMMC2 uses MMC device (otherwise define is not required)

Optional configuration:

  • Card Detect Pin:
    • Configure arbitrary pin in GPIO_Input mode and add User Label: MemoryCard_CD0
    • Alternatively, define MemoryCard_CDx_Pin_Extern and implement function MCI_ReadCD in application
  • Write Protect Pin:
    • Configure arbitrary pin in GPIO_Input mode and add User Label: MemoryCard_WP0
    • Alternatively, define MemoryCard_WPx_Pin_Extern and implement function MCI_ReadWP in application
  • Data Cache Management:
    • define Driver_MCI0_DCache {value}
      • value 0U = disable MCI instance DCache maintenance operations
      • value 1U = enable MCI instance DCache maintenance operations
      • default value is 1U
    • define Driver_MCI1_DCache {value}
      • value set as for MCI0 instance (see above)

STM32U575I-EV Board Configuration

These settings are relevant for this board, for different board please refer to the board schematic for proper configuration.

Link to STM32U575I-EV board schematic.

STM32CubeMX

Required peripherals for the STM32U575I-EV board are listed in the table below:

Peripheral Mode Description
SDMMC1 SD 4 bits Wide bus SDMMC1 Controller
PC8 Alternate Function Push Pull SDMMC1_D0 Pin
PC9 Alternate Function Push Pull SDMMC1_D1 Pin
PC10 Alternate Function Push Pull SDMMC1_D2 Pin
PC11 Alternate Function Push Pull SDMMC1_D3 Pin
PC12 Alternate Function Push Pull SDMMC1_CK Pin
PD2 Alternate Function Push Pull SDMMC1_CMD Pin
PI0 GPIO_Input Card Detect Pin
Note
All settings have to be configured as described in the procedure below. Important settings, typically the ones different from default, are emphasized in bold.

Pinout & Configuration tab

  1. In the Pinout view window click on a pin and select it's functionality:
    Pin Functionality
    PC8 SDMMC1_D0
    PC9 SDMMC1_D1
    PC10 SDMMC1_D2
    PC11 SDMMC1_D3
    PC12 SDMMC1_CK
    PD2 SDMMC1_CMD
    PI0 GPIO_Input

  2. Under Categories: Connectivity select SDMMC1:

    Mode:

    • Mode: SD 4 bits Wide bus

    Configuration:

    • Parameter Settings: not used
    • User Constants: not used
    • NVIC Settings: configured in later step (under Category: System Core: NVIC)
    • GPIO Settings: review settings, no change required
      Pin Name Signal on Pin Pin Context.. Pin Priv.. GPIO output.. GPIO mode GPIO Pull-up/Pull.. Maximum out.. Fast Mode User Label
      PC8 SDMMC1_D0 n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .
      PC9 SDMMC1_D1 n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .
      PC10 SDMMC1_D2 n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .
      PC11 SDMMC1_D3 n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .
      PC12 SDMMC1_CK n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .
      PD2 SDMMC1_CMD n/a n/a n/a Alternate Function Push Pull No pull-up and no.. High n/a .

  3. Under Categories: System Core select GPIO: Configuration:
    • GPIO:
      Pin Name Signal on Pin Pin Context.. Pin Priv.. GPIO output.. GPIO mode GPIO Pull-up/Pull.. Maximum out.. Fast Mode User Label
      PI0 n/a n/a n/a n/a Input mode Pull-up n/a n/a MemoryCard_CD0
  4. Under Categories: System Core select NVIC:

    Configuration:

    • NVIC:
      NVIC Interrupt Table Enabled Preemption Priority Sub Priority
      SDMMC1 global interrupt checked 0 0
    • Code generation:
      Enabled interrupt table Select for.. Generate Enable in.. Generate IRQ h.. Call HAL handler
      SDMMC1 global interrupt unchecked checked unchecked n/a

Clock Configuration tab

  1. Configure To SDMMC1,2 (MHz): 48

Project Manager tab

  1. Under Advanced Settings:

    Generated Function Calls:

    Generate Code Function Name Peripheral Inst.. Do not generate .. Visibility (Static)
    checked MX_SDMMC1_SD_Init SDMMC1 checked checked

Generate Code

Generate source code by clicking on the GENERATE CODE button on the toolbar.