1
votes

I am trying to interface sd card with STM32F4 but things are not working,code was developed using cubemx

  1. Interface is sdio 1 bit mode(due to pin constraints)
  2. SD card 8 Gb formated with default allocation size

Steps taken to debug:

I single step through the code fmount is successful but when I step through fopen there a error code at find_volume() returning FR_NOT_READY.

Hardware conections:

I have arduino micro SD breakout board with SPI pins so connection are

  • DI → SDIO_CMD
  • DO → SDIO_D0
  • SCLK → SDIO_SCLK

int main(void)
{
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

    /* Configure the system clock */
    SystemClock_Config();

    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    MX_SDIO_SD_Init();
    MX_FATFS_Init();

    HAL_Delay(1000);

    /* USER CODE BEGIN 2 */
    if(f_mount(&mynewdiskFatFs,(const TCHAR*)SD_Path, 0) == FR_OK)
    {
        if(f_open(&MyFile, "abc.txt",  FA_READ ) == FR_OK)
        {
            // GPIO_SetBits(GPIOD, GPIO_Pin_15);
            if(f_read(&MyFile, wtext, sizeof(wtext), (void *)&wbytes) ==FR_OK);
            {
                f_close(&MyFile);
            }
        }
    }

    while (1)
    {

    }
}
2
SD card won't work without CS (Chip select).Turbo J

2 Answers

0
votes
f_open(&MyFile, "abc.txt",  FA_READ )

See what are your config options in ffconf.h regarding file names.

Try using (FA_OPEN_EXISTING | FA_READ) flags.

Use f_open() repeatedly with 100ms interval, say 5 times, till it returns FR_OK.

-1
votes

Hi turboJ I am interfacing SD card using 1 bit wide SDIO mode so there is no use CS I guess