Skip to main content
Visitor II
July 22, 2021
Question

I am using STM32H7A3 board. I am trying to integrate SD Card using SPI. I am getting FR_DISK_ERR when I try to do f_mount. Attached source code.

  • July 22, 2021
  • 6 replies
  • 7866 views

When i tried to give Pull ups for SPI pins except SPI1_SCK, i am getting FR_NOT_READY error.

I am completely stuck in this issue.

Please have a look into this and provide a solution for me.

Thanks in advance.

Jestina

    This topic has been closed for replies.

    6 replies

    Graduate II
    July 22, 2021

    One could easily sink hours into this.

    Any strong reason for not using the SDMMC interface and the working code available for that?

    JJoy.1Author
    Visitor II
    July 23, 2021

    Hi,

    First i tried to implement using SDMMC interface. But 9 pin SD break out board is not available in our country. So i tried with SPI.

    Graduate II
    December 1, 2021

    " But 9 pin SD break out board is not available in our country" ?¿?¿

    https://www.sparkfun.com/products/12941

    Visitor II
    July 22, 2021

    You should take a look at this:

    https://01001000.xyz/2020-08-09-Tutorial-STM32CubeIDE-SD-card/

    And use the drivers that are linked in that post with the fatfs middleware. I got it successfully working on an stm32l476rg-nucleo with an SD card break out board from adafruit.

    Graduate II
    July 22, 2021

    0690X000006CGatQAG.jpgYes, the AdaFruit SPI implementation (see BSP) for NUCLEO is also a good starting point but the NUCLEO-L476RG also supports SDMMC and will be significantly faster.

    JJoy.1Author
    Visitor II
    July 23, 2021

    Please ignore the above update..

    spiselect() is returning 1.

    But

    do {

    res = xchg_spi(0xFF);

    } while ((res & 0x80) && --n);

    return res;

    res is having value 0xFF.

    JJoy.1Author
    Visitor II
    July 26, 2021

    @devtty

    I tried the SD card integration as per the link you mentioned. Do you have any idea on why i am getting send_cmd(CMD0, 0) is returning 0xFF.(user_diskio_spi.c line no.337)

    Jestina

    Visitor II
    July 26, 2021

    I cant quite be sure on why either. Your code does look fine. Maybe play around a bit more with the clock speeds. The command you mention is supposed to put the SD card into "SPI/Idle state". I would double check or triple check your connections to the board. Are you using some sort of breakout board for the SD card? How is it wired?

    JJoy.1Author
    Visitor II
    July 27, 2021

    Hi @devtty​  ,

    Thanks for your update. I double checked the connections and could not find anything wrong. I am using a 6 pin SD card break out board and its wired using jumper wires.

    Jestina

    Visitor II
    December 1, 2021

    Hi, did you find something? i had that code running on a STM32F4 and worked fine, now with the STM32H7 i am not being able to make it work...

    JJoy.1Author
    Visitor II
    December 2, 2021

    Hi DCajigal,

    PFA my code with SD card working in STM32H7A3.

    Thanks,

    Jestina

    Visitor II
    December 2, 2021

    Thank you so much!