cancel
Showing results for 
Search instead for 
Did you mean: 

Interface SD card with nucleo H743ZI 1Bit/4Bit

ManishNair
Associate III

How to interface SD card with STM32h743z1 nucleo borad ? Is there any working example? I generated code with cubeMx 5 and failed at the very first step.. I tried various threads regarding SD card and nothing helped me.

card initialization itself giving an error. While digging i noticed the program is looping arround a Delay(2);

Also when i measured the CLK at the SD card pin, it shows only 20Khz..

MY application is to store 12 Channel adc values in every sec (1sample per second).

21 REPLIES 21

One download per comment apparently...

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

Thank you, i will check and replay

ManishNair
Associate III

Thanks Clive... I tried this code.. but failed... first...

Then i tried the 4 wire socket with 4bit program it worked...

So i reprogrammed nucleo with 1bit hex...and used 4bit wired card. It worked....

I rewired the 1Bit socked with d0:3 like 4bit interface (the unused pins were left open for SPI interface amd pulled with 10K for SDMMC interface) and checked.... then also it worked and read the card...

So does the SDMMC requiers all 4bit, regardless of the bus width...

i removed the series 22 ohm resisters.... then also the program reads the card size and some parameters but i cant find anything in the counter.004 file

So the hardware setup is working .

Is the code generated by CubeMx is worng?

ManishNair
Associate III

Hi,

I deleted almost 50 code attempts and projects to interface SD card to sdmmc, which all ended in same result, FR_not ok... As a final attempt i generated a new project and wrote very a simple 1B code..

 char myProb[] = "STM32.TXT";

 char myLoss[] = "JUNK.TXT";

 char myData[] = "This card is Like ST ! Never answer!";

 char myRead[100];

 UINT testbyte;

 if ( f_mount(&SDFatFS, SDPath,1) == FR_OK)

 {

printf("card mounted \n\r");

f_open(&MyFile,myProb, FA_WRITE|FA_CREATE_ALWAYS);

f_write(&MyFile,myData, sizeof(myData), &testbyte );

f_close(&MyFile);

printf("file created \n\r");

HAL_Delay(1000);

printf("ReadinG \n\r");

f_open(&MyFile, myLoss, FA_READ |FA_OPEN_ALWAYS);

f_read(&MyFile,myRead,sizeof(myRead) , &testbyte );

f_close(&MyFile);

HAL_Delay(1000);

printf("file CONTENT = \n\r");

printf( myRead);

printf(" \n\r");

 }

 else

 {

printf ("Card Mount failed");

 }

But it worked...!

I tried another card, It stopped/hanged... When i checked the cards; i noticed only SD cards can interface. For SDHC cards, the program gets hanged some where else... Also 4b interface...

Is the SD FatFs middlewere in cube Mx only support 1b SD cards.... ?

Is there any solution?

Errors in low level code will be very hard to debug from the top level.

You'll need to instrument and debug the low level code to understand the failure mechanism.

I would recommend the use of DMA, and backing off the slew rates on the pins.​

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

Another build 4-bit 33 MHz using DMA, and providing integrity checking mode to fill media and validate.

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

Hi! Can you share the source code of your test firmware?

It is available, but not free.

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

Have you find a way to get the job? Kindly share your experience with stm32.

Actually i want to interface a sdmmc with nucleoh743.

i want to build a system that can transfer files from pc to sdmmc via nucleo. the communication with pc is done with the help of USB-VCP but i want to further send and store that data in sdmmc

AKhan.364
Associate II

Any help would be highly appreciated.