Skip to main content
Associate II
May 2, 2024
Question

STM32H745 SDMMC block reads returning empty

Hello, 

I am working on trying to get the SDMMC1 on the stm32h745 to function properly. Currently I have this for my current initialization of the SDMMC and it does not return any errors. 

hsd1.Instance = SDMMC1;
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; 
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd1.Init.ClockDiv = 0;

if (HAL_SD_Init(&hsd1) != HAL_OK) {
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B) != HAL_OK) {
Error_Handler();
}

 

After this is done, I try to use the HAL_SD_ReadBlocks_IT(); and also this does not return any errors. The issue I am having is the return data buffer has no data in it when this function finishes. Currently I am not sure what the issue might be, the clocks and appear as they are sending data but I am getting nothing in my return data. Any thoughts or ideas on what might resolve this problem? 

Thanks 

This topic has been closed for replies.

12 replies

AScha.3
Super User
May 2, 2024

Hi,

so you want use sdcard - right ?

And no file system , no fatfs , no mount  ?

Anyway - at first stay on 1 bit mode . (After working fine, can try 4 bit ..more critical)

If you feel a post has answered your question, please click on " Best Answer ".
Matt__Author
Associate II
May 2, 2024

Yes I am using a sd card and will eventually implement fatfs, but was trying to get the SDMMC to work first. I am currently having no luck in getting the system to get any data running in 1 bit mode. 

AScha.3
Super User
May 2, 2024

Ok, i can only tell, how i did (always):

install/set in Cube fatfs , sdcard ...etc. (no dma );

then first use a working sdcard , try mount . If this working...you win the price . :)

fresult = f_mount(&SDfs, (TCHAR const*)SDPath, 1);	// SD card mount, 1 = now !

fresult = 0 =  no error . (As long this is not working, you have a hardware problem.)

First important thing: hardware ->

(in Cube) sd-pins setting : set on all pins : pullup , speed medium ; clk (i use ) 100MHz , div 1 (-> 50MHz for card).

And short lines to card , cpu -- card : max. 50mm (otherwise...good luck. )

If you feel a post has answered your question, please click on " Best Answer ".
ST Technical Moderator
May 7, 2024

Hello @Matt__ 

 

Please refer to the example STM32H743I-EVAL/Examples/SD/SD_ReadWrite_IT  to check what is missing in your application. 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
EXUE.2
ST Employee
May 9, 2024

Hello @Matt__ 

1.for your code, since you configure BisWide to 1B by  "hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; ", why you configure BisWide to 4B later by "if (HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B) != HAL_OK)"?

below is my code:

/* uSD device interface configuration */
hsd->Instance = SDMMC1;
hsd->Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd->Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd->Init.BusWide = SDMMC_BUS_WIDE_4B;
hsd->Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
// (SD ker CLK: 200M) SDMMC_HSpeed_CLK_DIV(2) or SDMMC_NSpeed_CLK_DIV(4)
hsd->Init.ClockDiv = 4;
#if (USE_SD_TRANSCEIVER != 0U)
// 1V8 Transceiver/Switcher not present
hsd->Init.TranceiverPresent = SDMMC_TRANSCEIVER_NOT_PRESENT;
#endif /* USE_SD_TRANSCEIVER */

/* HAL SD initialization */
if(HAL_SD_Init(hsd) != HAL_OK)
{
     ret = HAL_ERROR;
}

if(HAL_SD_ConfigWideBusOperation(&hsd_sdmmc[Instance], SDMMC_BUS_WIDE_4B) != HAL_OK)
{
    ret = BSP_ERROR_PERIPH_FAILURE;
}

(void)HAL_SD_ConfigSpeedBusOperation(&hsd_sdmmc[Instance], SDMMC_SPEED_MODE_HIGH);

2. I have met similar problem before, the root cause is that the SD card have several kinds, high-speed and low-speed, when I insert the low-speed SD card, it didn't work, but when I insert high-speed card, it worked, so can you check if your problem is same as mine?