cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure SD CARD via STM32CubeIDE

DYann.1
Senior II

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

Hello,

I have this example as I said at the beginning of my topic. And in this example (FatFs_uSD_Standalone) I have this code in the function void SystemClock_Config(void) :

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Configure the main internal regulator output voltage
  */
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE0) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
  RCC_OscInitStruct.PLL.PLLM = 1;
  RCC_OscInitStruct.PLL.PLLN = 55;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
  RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
  {
    Error_Handler();
  }
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_SDMMC1;
  PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
}

 This part of code is very strange and misplaced

DYann1_0-1719334021438.png

I was looking for something that I already had since I configured it in my .ioc file via STM32Cube IDE but which is placed elsewhere not in the function 'void SystemClock_Config(void)' but in the function 'void HAL_SD_MspInit(SD_HandleTypeDef* hsd)'. Thus It's impossible to compare to something that is not comparable. Why are you hiding the '.ioc' file in the FatFs_uSD_Standalone example ? What is your interest in wasting developers' time ?


Why are you hiding the '.ioc' file in the FatFs_uSD_Standalone example ? What is your interest in wasting developers' time ?

At the time STM32L5 series released we don't provide ioc files in its CubeHAL examples such as many older STM32 products. We are here to help you as we can. So no need to be aggressive.

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:

At the time STM32L5 series released we don't provide ioc files in its CubeHAL examples such as many older STM32 products. We are here to help you as we can. So no need to be aggressive.


Hello,

I wanted to say that it is complicated for a beginner to find the configuration parameters via the '.ioc' file. A copy of a portion of code here and there becomes quite complicated for me. My project has fallen far behind schedule but I am in no way aggressive, rest assured.

Thank you for your helps.

DYann.1
Senior II

Hello,

I would like to know how to have the configuration have the same code from the STM example via the .IOC file. 

The example has this code

DYann1_0-1719478136600.png

Via my STM32CubeIDE, after configuring my Clock Configuration I can have this code

DYann1_1-1719478379884.png

I'm missing this line below, is this really important ?

DYann1_2-1719478464404.png

And my .ioc file has a red cross

DYann1_3-1719478673798.png

Do you have any idea how to configure my clock to have the same code as the example provided by STM ? Thank you for your helps.

Regards