CMSIS-Driver_STM32  
CMSIS Drivers for STMicroelectronics STM32 Series devices
 
Loading...
Searching...
No Matches
MCI

Revision History

  • Version 3.0
    • Initial release

Requirements

This driver requires the STM32 device specific HAL and STM32CubeMX (CubeMX) initialization code generator. The driver instance is mapped to hardware as shown in the table below:

CMSIS Driver Instance STM32 Hardware Resource
Driver_MCI1 SDMMC1 or SDIO
Driver_MCI2 SDMMC2

CubeMX Configuration

This driver requires the following configuration in CubeMX:

  • When using SDMMC peripheral:
    • clock: SDMMC peripheral clock.
    • peripheral: SDMMC peripheral configured in SD or MMC mode.
    • pins: CMD, CK, D0 - D3 and for 8-bit MMC optionally D4 - D7.
    • interrupts:
      • enabled SDMMC global interrupt with Generate Enable in Init and without Generate IRQ handler
    • project manager: enabled Do Not Generate Function Call in Advanced Settings for MX_SDMMCx_SD_Init
  • When using SDIO peripheral:
    • clock: SDIO peripheral clock.
    • peripheral: SDIO peripheral configured in SD or MMC mode.
    • pins: CMD, CK, D0 - D3 and for 8-bit MMC optionally D4 - D7.
    • DMA: DMA stream configuration.
    • interrupts:
      • enabled SDIO global interrupt with Generate Enable in Init and without Generate IRQ handler
      • enabled SDIO_RX and SDIO_TX DMA Requests that Call HAL handlers.
    • project manager: enabled Do Not Generate Function Call in Advanced Settings for MX_SDIO_SD_Init
  • Optionally Card Detect or Write Protect pin may be configured:
    • Chose any general purpose pin as input and add User Label:
      • MemoryCard_1_CD to add Card Detect pin for SDMMC1 or SDIO
      • MemoryCard_1_WP to add Write Protect pin for SDMMC1
    • Similar for SDMMC2, add User Label as below:
      • MemoryCard_2_CD
      • MemoryCard_2_WP

Notes

  • configuration information in the MX_Device.h file is based on CubeMX configuration.
  • DMA configuration can differ between devices series so configure DMA as required by the used device.
  • for DMA usage on devices with cache, ensure that data buffers for Transmit and Receive functions are in non-cacheable memory, or ensure that memory for transmit is updated (cache clean) before Transmit function is called and that memory containing received data is updated after the reception finishes (cache invalidate).
  • some DMA controllers can only access specific memories, so ensure that proper memory is used for the buffers according to the DMA requirement.

Example

Pinout & Configuration tab

  1. Under Categories: Connectivity select SDMMC1:

    Mode:

    • Mode: SD 4 bits Wide bus

    Configuration:

    • Parameter Settings: not required
    • User Constants: not required
    • NVIC Settings:
      NVIC Interrupt Table Enabled Preemption Priority Sub Priority
      SDMMC1 global interrupt checked 0 0

    • GPIO Settings:
      Pin Name Signal on Pin GPIO output.. GPIO mode GPIO Pull-up/Pull.. Maximum out.. Fast Mode User Label
      PC8 SDMMC1_D0 n/a Alternate Function Push Pull Pull-up Very High n/a .
      PC9 SDMMC1_D1 n/a Alternate Function Push Pull Pull-up Very High n/a .
      PC10 SDMMC1_D2 n/a Alternate Function Push Pull Pull-up Very High n/a .
      PC11 SDMMC1_D3 n/a Alternate Function Push Pull Pull-up Very High n/a .
      PC12 SDMMC1_CK n/a Alternate Function Push Pull Pull-up Very High n/a .
      PD2 SDMMC1_CMD n/a Alternate Function Push Pull Pull-up Very High n/a .
      • Use the Pinout view window to reconfigure pins when custom pin selection is required
  2. 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 checked

  3. In the Pinout view window click on a Card Detect/Write Protect pin and select it's functionality:
    • Functionality:
      Pin GPIO mode
      PI8 GPIO_Input
      PI0 GPIO_Input

  4. Under Categories: System Core select GPIO:

    Configuration:

    • GPIO:
      Pin Name Signal on Pin GPIO output.. GPIO mode GPIO Pull-up/Pull.. Maximum out.. Fast Mode User Label
      PI8 n/a n/a Input mode Pull-up n/a n/a MemoryCard_1_CD
      PI0 n/a n/a Input mode Pull-up n/a n/a MemoryCard_1_WP

Clock Configuration tab

  1. Configure To SDMMC1,2 (MHz): 240
    • Usually clock can be configured to max frequency.

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