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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 05:01 AM
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
- Labels:
-
FatFS
-
SPI
-
STM32H7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 10:41 AM
One could easily sink hours into this.
Any strong reason for not using the SDMMC interface and the working code available for that?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 01:46 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 02:36 PM
Yes, 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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 11:56 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 03:38 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 05:15 AM
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..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 05:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 05:31 AM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-25 11:36 PM
@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