cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-Disco429 SDIO + SD CARD init

s3322513
Associate
Posted on September 20, 2014 at 04:23

Hello

Micro controller = STMF32DISCO429.

SD card reader = 

SD/MMC CARD BREAKOUT 

BOB-12941

SD CARD = 16mb Hp invent Sandisk card 0210ln Library = STM32Cube_FW_F4_V1.3.0

Hello, ive been trying to set up a sd card just so i can read and initialize it, below is my attached code and how im going about it all, ive noticed on this forum that there have been alot of errors with the cube libary and the SDIO, ive noticed that PC10 SDIO_D02 is also connect to the LCD which can be problematic, is my initialization code correct or am i missing something? i seem to be getting the timeout errors and the code is sitting in

 while((timeout > 0) && (!tmp))

  {

    tmp = __HAL_SD_SDIO_GET_FLAG(hsd, SDIO_FLAG_CMDSENT);

    timeout--;

  }

under ''stm32F4xx_hal_sd.c'', any help would be greatly appreciated!, is it possible the sd card is to old? ive wired up the sd accordingly with the appropriate pullup resistors of 47k, unfortunately i don't have access to a oscilloscope :( any guidance on where i can start understanding why its failing to read the SD card? what are some appropriate testing methods that can help me pinpoint the problem?

Thanks!

//----- code -------

  /* Add your application code here

     */

   SD_HandleTypeDef a;

  HAL_SD_CardInfoTypedef b;

GPIO_InitTypeDef GPIO_InitStructure;

a.Instance = NULL;

   

//d0-d3

__GPIOC_CLK_ENABLE();

GPIO_InitStructure.Pin = GPIO_PIN_8 | GPIO_PIN_9 |GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;

GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;

  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStructure.Pull = GPIO_PULLUP;

GPIO_InitStructure.Alternate = GPIO_AF12_SDIO;

  HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

//cmd line

__GPIOD_CLK_ENABLE();

GPIO_InitStructure.Pin = GPIO_PIN_2;

GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;

  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStructure.Pull = GPIO_NOPULL;

GPIO_InitStructure.Alternate = GPIO_AF12_SDIO;

  HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);

//init card

__SDIO_CLK_ENABLE();

HAL_SD_Init(&a,&b);

1 REPLY 1
Posted on October 21, 2014 at 16:49

Hi,

To have enough insight on how to drive the micro SD external card, you can refer to the stm324x9i_eval_sd.c file available under the STM32Cube_FW_F4 package: \Firmware\Drivers\BSP\STM324x9I_EVAL

It may helps you to understand the main steps to initialize the SD and the to configure the SDIO interface properly.

PS: Please Format Code Block - Paintbrush [<>] icon, upper left of Word-in-a-box(tm) interface..

Regards,

Heisenberg.