EasyManuals Logo

ST STM32F2 User Manual

ST STM32F2
1371 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #357 background imageLoading...
Page #357 background image
UM1940
HAL MMC Generic Driver
DocID028236 Rev 2
357/1371
MMC Card Initialization and configuration
To initialize the MMC Card, use the HAL_MMC_Init() function. It Initializes SDMMC IP
(STM32 side) and the MMC Card, and put it into StandBy State (Ready for data transfer).
This function provide the following operations:
1. Initialize the SDMMC peripheral interface with defaullt configuration. The initialization
process is done at 400KHz. You can change or adapt this frequency by adjusting the
"ClockDiv" field. The MMC Card frequency (SDMMC_CK) is computed as follows:
SDMMC_CK = SDMMCCLK / (ClockDiv + 2) In initialization mode and according to
the MMC Card standard, make sure that the SDMMC_CK frequency doesn't exceed
400KHz. This phase of initialization is done through SDMMC_Init() and
SDMMC_PowerState_ON() SDMMC low level APIs.
2. Initialize the MMC card. The API used is HAL_MMC_InitCard(). This phase allows the
card initialization and identification and check the MMC Card type (Standard Capacity
or High Capacity) The initialization flow is compatible with MMC standard. This API
(HAL_MMC_InitCard()) could be used also to reinitialize the card in case of plug-off
plug-in.
3. Configure the MMC Card Data transfer frequency. By Default, the card transfer
frequency is set to 24MHz. You can change or adapt this frequency by adjusting the
"ClockDiv" field. In transfer mode and according to the MMC Card standard, make
sure that the SDMMC_CK frequency doesn't exceed 25MHz and 50MHz in High-
speed mode switch. To be able to use a frequency higher than 24MHz, you should
use the SDMMC peripheral in bypass mode. Refer to the corresponding reference
manual for more details.
4. Select the corresponding MMC Card according to the address read with the step 2.
5. Configure the MMC Card in wide bus mode: 4-bits data.
MMC Card Read operation
You can read from MMC card in polling mode by using function
HAL_MMC_ReadBlocks(). This function allows the read of 512 bytes blocks. You can
choose either one block read operation or multiple block read operation by adjusting
the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is
done correctly. The check is done through HAL_MMC_GetCardState() function for
MMC card state.
You can read from MMC card in DMA mode by using function
HAL_MMC_ReadBlocks_DMA(). This function allows the read of 512 bytes blocks.
You can choose either one block read operation or multiple block read operation by
adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the
transfer is done correctly. The check is done through HAL_MMC_GetCardState()
function for MMC card state. You could also check the DMA transfer process through
the MMC Rx interrupt event.
You can read from MMC card in Interrupt mode by using function
HAL_MMC_ReadBlocks_IT(). This function allows the read of 512 bytes blocks. You
can choose either one block read operation or multiple block read operation by
adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the
transfer is done correctly. The check is done through HAL_MMC_GetCardState()
function for MMC card state. You could also check the IT transfer process through the
MMC Rx interrupt event.
MMC Card Write operation
You can write to MMC card in polling mode by using function
HAL_MMC_WriteBlocks(). This function allows the read of 512 bytes blocks. You can
choose either one block read operation or multiple block read operation by adjusting
the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F2 and is the answer not in the manual?

ST STM32F2 Specifications

General IconGeneral
BrandST
ModelSTM32F2
CategoryMicrocontrollers
LanguageEnglish

Related product manuals