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

Having things working here.

Considerations, good socket, with pull-ups, and uniform/short wiring.

Watch that you don't use overly aggressive edges (slew rate) for the IO pins.

Remove SB116/SB117 to eliminate stubs.

I would avoid writing small amounts to card repetitively, it is slow and creates excessive read-modify-write to the flash array.

Will see if I have a working demo to hand.

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

NUCLEO-H743ZI SDMMC Test Build

Outputs diagnostic via ST-LINK VCP at 115200 8N1

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

Thanks Clive,

I already Noticed/followed your recommendations. tried 10K/27K/47K pull ups, series 27Ohm resistors, removed SB116 and 117. tried Card with directly soldered Short wires and another one in Holder. Tried 1bit and 4bit. but The program is hanging in a HAL_Delay(2); .

However the same card and setup(1bit) works instantly with the SPI "FatFS_uSD_Standalone" application in nucleo FW and i can read/write /format etc.

Also i will transfer the data once in a minute or with block of 512 as per your advice.

  1. Can you Help me with the steps after Cube Mx Generation?
  2. My steps -> Selected Nucleo144 -> h747 board -> disabled ETH,USB -> enabled UART3-> LEDs-> SDMMC1 (SD 1bit/no voltage setup/ PE11 as sdio detect/ Intr enabled) -> MDMA-> Added transmit for SDmmC1 (Bfr 1, byte, byte) -> Ii&D caches-> Fatfa (SD card) -> heap 2kb/ stack 4k b -> truestudio and generated the code
  3. iN main.c only two files included "main.h" and fatfs.h.
  4. Can I directly write the Programs with Fatfs variables and card initialisation and i seen in theFatFs_uSD_Standalone example in STM32H743I_EVAL folder.. or shall i have to define any other sd/other functions? or any special initialisation calls?
  5. ALso any help or tutorial to understand when/where/how the bytes are transferred to transmitter... in SPI example i noticed a SCK/MISO/MOSI pin/port declaration and an spi bytewrite function, while digging up the fatfs file. But i never noticed any SDIO pin declaration in the code generated by the CubeMX. is it defined by the HW?
  6. Is there any link, where we can get the example codes for H7X3? i noticed such a reference manual /user manual etc..

ManishNair
Associate III

Thanks Clive,

I already Noticed/followed your recommendations. tried 10K/27K/47K pull ups, series 27Ohm resistors, removed SB116 and 117. tried Card with directly soldered Short wires and another one in Holder. Tried 1bit and 4bit. but The program is hanging in a HAL_Delay(2); .

However the same card and setup(1bit) works instantly with the SPI "FatFS_uSD_Standalone" application in nucleo FW and i can read/write /format etc.

Also i will transfer the data once in a minute or with block of 512 as per your advice.

  1. Can you Help me with the steps after Cube Mx Generation?
  2. My steps -> Selected Nucleo144 -> h747 board -> disabled ETH,USB -> enabled UART3-> LEDs-> SDMMC1 (SD 1bit/no voltage setup/ PE11 as sdio detect/ Intr enabled) -> MDMA-> Added transmit for SDmmC1 (Bfr 1, byte, byte) -> Ii&D caches-> Fatfa (SD card) -> heap 2kb/ stack 4k b -> truestudio and generated the code
  3. iN main.c only two files included "main.h" and fatfs.h.
  4. Can I directly write the Programs with Fatfs variables and card initialisation and i seen in theFatFs_uSD_Standalone example in STM32H743I_EVAL folder.. or shall i have to define any other sd/other functions? or any special initialisation calls?
  5. ALso any help or tutorial to understand when/where/how the bytes are transferred to transmitter... in SPI example i noticed a SCK/MISO/MOSI pin/port declaration and an spi bytewrite function, while digging up the fatfs file. But i never noticed any SDIO pin declaration in the code generated by the CubeMX. is it defined by the HW?
  6. Is there any link, where we can get the example codes for H7X3? i noticed such a reference manual /user manual etc..

Thank you for the code.. i tested it and got the following results

 Nucleo H743ZI

 Core=400000000, 400 MHz

CPUID 411FC271 DEVID 450 REVID 1003

 Cortex M7 r1p1

 STM32H7xx

 C0000038 24013780 00000000

 10110221 12000011 00000040

 FPU-D Single-precision and Double-precision

 HCLK=200000000 APB1=100000000

 APB2=100000000

 FatFs Testing (68300)

 Mounting FatFs

 BSP_SD_MspInit

 SD_PowerON Failed (HAL_SD_InitCard)

 HAL_SD_InitCard Failed

 HAL_SD_Init Failed

 res = 3 f_getfree

 PLL1_Q_CK=200000000, 200.00 MHz

 PLL2_R_CK=0, 0.00 MHz

SDMMC_CK 250, 0.40 MHz

 Infinite loop...

Nucleo H743ZI  Core=400000000, 400 MHz

 CPUID 411FC271 DEVID 450 REVID 1003

 Cortex M7 r1p1

 STM32H7xx  C0000038 24013780 00000000 10110221 12000011 00000040

 FPU-D Single-precision and Double-precision

 HCLK=200000000  APB1=100000000 APB2=100000000

FatFs Testing (68300)

Mounting FatFs

BSP_SD_MspInit

CardInfo 15126528 512 512 ( 7.21 GB)

Nucleo H743ZI

 Core=400000000, 400 MHz

 CPUID 411FC271 DEVID 450 REVID 1003

 Cortex M7 r1p1

 STM32H7xx

 C0000038 24013780 00000000

 10110221 12000011 00000040

 FPU-D Single-precision and Double-precision

HCLK=200000000  APB2=100000000

FatFs Testing (68300)

Mounting FatFs

 BSP_SD_MspInit

 CardInfo 7716864 512 512 ( 3.68 GB)

res = 3 f_getfree

 PLL1_Q_CK=200000000, 200.00 MHz

PLL2_R_CK=0, 0.00 MHz

SDMMC_CK 2, 50.00 MHz

 Infinite loop...

but there is no file action noticed in the card... may be not written

Presumably the cards are formatted/usable in a PC.

There is likely an issue with the wiring. I will make a slower and 1-bit variant.

The pin expectations are these

    //
    // NUCLEO-144 SDIO/SDMMC
    //          CN8
    ///       NC   PC8  (D0)
    //     IOREF   PC9  (D1)
    //     RESET   PC10 (D2)
    // (3V3) 3V3   PC11 (D3)
    //        5V   PC12 (CLK)
    // (GND) GND   PD2  (CMD)
    //       GND   PG2 PF3  (CS) 
    //       VIN   PG3 PF5  (WP)
    //

Using a WaveShare/ViewTool socket

https://www.waveshare.com/micro-sd-storage-board.htm

https://www.waveshare.com/SD-Storage-Board.htm

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

I'm not using CubeMX, I work more directly with HAL code, and code bases that span multiple STM32 families.

The pin configuration can either be in-line, in a BSP package, or in an MSP file for the project. In the MSP there is a callback for the SDIO/SDMMC initialization there should be code to enable clocks and set up pins, etc. Perhaps grep/search your source trees for GPIO_PIN_2.

I built a NUCLEO-144 BSP file for SDMMC support.

There should be assorted code examples under the HAL H7 trees in the repository. The EVAL board has more specific examples, but there should be stand-alone SDMMC examples, and ones in Applications/FatFs or Applications/Display, JPEG, etc using the cards. Use a File Manager or grep to search on "BSP_SD_Init"

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

Thread covering H7 SDMMC, cross linking so I can find it later. https://community.st.com/s/question/0D50X0000ADDM8DSQX/stm32h743-unreliable-micro-sd-transfers

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

25 MHz 1-bit and 4-bit modes

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