cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3Discovery: SD CARD with SPI INTERFACE using FATFS

alkuor
Associate II
Posted on October 09, 2016 at 06:06

Hi, I am looking to have sd card  interfaced with SPI using FATFS library, I have spent a lot of time trying to figure out how to do it but without any success. Could anyone help me with that? Thanks.

4 REPLIES 4
Posted on October 09, 2016 at 18:39

I have spent a lot of time trying to figure out how to do it but without any success

Unfortunately that imparts no information about what you have done, or how close to getting it working you might have come. I'm not looking to rework a complete solution from scratch. So let's try and leverage the time you've already spent productively.

There are a number of STM32 board designs using SPI SD Card attachment. Have you reviewed those? How have you wired your solution? EVAL, Olimex, eBay, TaoBao, etc.

There are a number of software examples that are almost certainly portable to the STM32F3-DISCO platform. The EVAL series boards being a prime example, but there are others.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Senior II
Posted on October 10, 2016 at 15:41

Hi alkuor.abdelraheem, 

You can get help from the following resources :

* User manual

http://www.st.com/content/ccc/resource/technical/document/user_manual/61/79/2b/96/c8/b4/48/19/DM00105259.pdf/files/DM00105259.pdf/jcr:content/translations/en.DM00105259.pdf

''Developing Applications on STM32Cube with FatFs''

* ''FatFs_uSD'' firmware example in

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef3.html

 which is an application that uses most of the features offered by FatFs to configure a microSD drive, at this path:  STM32Cube_FW_F3_V1.6.0\Projects\STM32303C_EVAL\Applications\FatFs\FatFs_uSD

-Hannibal-

alkuor
Associate II
Posted on November 30, 2016 at 16:35

Hi, thank you for your reply.  I am sending the correct command and I can see it on the scope.However, I don't get 0x01 response(I keep getting 0xff) from SDcard(SDHC)(SanDisk Ultra 40MB/s ...16GB) I am using the following code:  uint8_t cmd0[6]={0x40,0x00,0x00,0x00,0x00,0x95};

uint8_t dumb=0xff;

FATFS_CS_HIGH;

for (int i = 0; i < 10; i++) {

HAL_SPI_Transmit(&hspi1, &dumb, 1, 10);

while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);

}

FATFS_CS_LOW;

HAL_SPI_Transmit(&hspi1, cmd0, 6, 10);

while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);

for (int i = 0; i < 2; i++) {

HAL_SPI_Transmit(&hspi1, &dumb, 1, 10);

while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);

HAL_SPI_Receive(&hspi1, &c, 1, 10);// I keep getting 0xff

}

Posted on November 30, 2016 at 17:02

This is the third thread you have opened on this same topic/theme

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