cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure SD CARD via STM32CubeIDE

DYann.1
Senior

Hello,

I would like to know how to configure the SD card of an STM32L552E-VE evaluation board, I have an example with this evaluation card 'FatFs_uSD_Standalone' but It's not easy for me to understand how to configure the 'SDMMC' with this board since there is no '.IOC' file. I have the example code but not the '.IOC' configuration file. Can anyone tell me how to configure the SD card via STM32CubeIDE ?

Thank you for helps.

13 REPLIES 13
SofLit
ST Employee

Hello,

This video shows how to configure SD interface using CubeMx for FatFs file system usage .

Hope it helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@SofLit wrote:

Hello,

This video shows ho to configure SD interface using CubeMx for FatFs file system usage .

Hope it helps.


Hello,

Thanks, I'll look at it...

DYann.1
Senior

Hello,

I can see the video but in this step I don't have the same configuration

DYann1_0-1719219843669.png

And my evaluation card does not have a DMA tab? Maybe I'm missing a library ?

DYann1_1-1719219983127.png

Yet the NVIC is activated. Probably the STM32F7 board is not the same as STM32L5 that why I don't have the DMA tab ?

Thanks

Elhem_ZAY
ST Employee

Hello,
this config of SD card on STM32L552E-VE board can help you. If you use SD card for the application 'FatFs_uSD_Standalone' must enable SDMMC1 global interrupt.

I will be waiting for your feedback.
Elhem_ZAY_0-1719223637287.pngElhem_ZAY_1-1719223675305.pngElhem_ZAY_2-1719223698869.pngElhem_ZAY_3-1719223723527.png

Hello M. Elhem,

Thank you for this information, after having verified I don't have the SD card but the µSD card, I think it's the same communication protocol for both ? Should I check the box 'NVIC Interrupt Table' or not ? After your previous picture we don't  validate NVIC Interrupt Table.

When I try to generate de code by STMCubeIDE I have this message :

DYann1_0-1719232941183.png

Thanks

Hello,

After login and download the update now i can have the code, now I can compare with the example code. Thank you.

DYann.1
Senior

Hello,

After comparing the code I more or less found the configuration via CubeMX but I don't know where to find this information ? Could you tell me where they are located in the CLock configuration window ?

DYann1_0-1719318452797.png

Thank you for your helps

Regards

 

From the clock configuration menu and set SDMMC1 clock source to PLLP:

SofLit_0-1719321803781.png

 

The related generated code will be available le in stm32l5xx_hal_msp.c:

void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  if(hsd->Instance==SDMMC1)
  {
  /* USER CODE BEGIN SDMMC1_MspInit 0 */

  /* USER CODE END SDMMC1_MspInit 0 */

  /** Initializes the peripherals clock
  */
    PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_SDMMC1;
    PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLLP;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
    {
      Error_Handler();
    }

:

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Elhem_ZAY
ST Employee

Hello,
Clock Config of SD is correct and it is located in "SystemClock_Config" function.
Please find attached this lien of "FatFs_uSD_Standalone" application on STM32L552E-EV can help you :
https://github.com/STMicroelectronics/STM32CubeL5/tree/master/Projects/STM32L552E-EV/Applications/FatFs/FatFs_uSD_Standalone

you can compare your code generated with CubeMX with this application.
Good work.
Best regards.