cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS - SD-Card Code created using STM32CubeMX V.5.0

GS1
Senior III

In my project for our STM32H743 board we need to access an SD-Card (SDMMC1) with FatFs.

The supplied sample code for the eval boards is not created with CubeMX and therefore the structure is different and does not really help.

I tried to implement a simple read directory function, but the SD-card state is not turning to "Ok".

Card-Detect is working, Clock is output at 25 MHz, Signals look ok when booting the system (400 kHz, 25 MHz), CMD signals are coming, but then the file systems fails.

Has anybody tried to implement this using STM32CubeMX?

Is it enough to simply activate the MDMA Transfer1 for SDMMC1 data end using the default entries? Any recommendations for the Request Settings?

Any help is very much appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
GS1
Senior III

Problem solved!

SD Card is running now. The reason was, that USE_SD_TRANSCEIVER was automativally set to 1 by Cube. But we do not have a transceiver, so this must be set to 0.

Don't know yet, where to configure this in STM32CubeMX as this will be set again with the next "Generate Code"...

View solution in original post

3 REPLIES 3
GS1
Senior III

Problem solved!

SD Card is running now. The reason was, that USE_SD_TRANSCEIVER was automativally set to 1 by Cube. But we do not have a transceiver, so this must be set to 0.

Don't know yet, where to configure this in STM32CubeMX as this will be set again with the next "Generate Code"...

JGawe
Associate

Hello, I see that you mentioned the comparison of fatfs implementation, in the example provided for the eval plate and the one generated in CubeMX. I am trying to do support for removing and inserting an SD card during uC operation. I like the card initialization in the supplied sample for stm32l4-eva (but I hope that that is similar for STM32H7) but it is a bit different than in the code generated by CubeMX, for now I would be using the code from CubeMX, hence the question :if I can do when inserting the card

FATFS_LinkDriver (& SD_Driver, SDPath);
f_mount (& SDFatFS, (TCHAR const *) SDPath, 0);

and when pulling:

FATFS_UnLinkDriver (char * path);
f_mount (NULL, (TCHAR const *) "", 0);

will the card be correctly reinitialized? I did not meet anyone doing FATFS_UnLinkDriver while the program was running, always only at the end of the program for uC ;/

Hello Jakub, in my application I will not need to change the SD card during operation and we always advise our customers to stay away from unplugging the SD card while the system is running. In case the operator unplugs the card while the FAT is written, the file system would be destroyed. So we think it is not a good idea to allow unplugging the card during operation. I didn't try this feature and therefore can not tell, if the card will be initialized correctly. Simply try and you will see what happens.