cancel
Showing results for 
Search instead for 
Did you mean: 

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.

JJoy.1
Associate III

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

15 REPLIES 15

One could easily sink hours into this.

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
devtty
Associate III

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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Hi,

Thanks for the reply.

I have created new code as per the below link and used the driver files mentioned there.

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

Entire source code is attached here.

In user_diskio_spi.c file - line no. 337 - (send_cmd(CMD0, 0) is returning 0xFF.

I am using SDHC SanDisk card of size 16GB.

I tried with FCLK_FAST(); and FCLK_SLOW(); - Both are giving the same result.

I am using STM32H7A3 board.

A small update..

static

int spiselect (void) /* 1:OK, 0:Timeout */

{

CS_LOW(); /* Set CS# low */

xchg_spi(0xFF); /* Dummy clock (force DO enabled) */

if (wait_ready(500)) return 1; /* Wait for card ready */

despiselect();

return 0; /* Timeout */

}

This is returning 0 (Timeout) every time..

JJoy.1
Associate III

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.

Unfortunately there's probably not a lot of debugging support, try the library author for consultancy

Could be something electrical, so pull-ups, or how the chip-select transition before/after the transaction, or basic connectivity.

A scope or logic analyzer might help in this regard, as well as an understanding of the protocol for the SD/MMC cards.

STM32Cube_FW_H7_V1.8.0\Drivers\BSP\Adafruit_Shield\adafruit_802_sd.c

STM32Cube_FW_H7_V1.8.0\Projects\NUCLEO-H743ZI\Applications\FatFS\FatFS_uSD_Standalone\Src\stm32h7xx_nucleo_bus.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JJoy.1
Associate III

@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