2024-05-02 11:10 AM
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
2024-05-02 11:46 AM
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)
2024-05-02 12:03 PM
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.
2024-05-02 12:25 PM
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. )
2024-05-07 07:17 AM
Hello @Matt__
Please refer to the example STM32H743I-EVAL/Examples/SD/SD_ReadWrite_IT to check what is missing in your application.
2024-05-09 02:39 AM
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?
2024-05-09 11:54 AM
So I was able to get the f_mount to succeed but only at low speeds. Currently I cannot figure out how to get past 6Mhz at 4 bits bandwidth and have the f_mount succeed. I have tried adjusting the clocks in the cubemx but can't seem to get any faster. Any ideas of what might be limiting this?
2024-05-09 12:25 PM - edited 2024-05-09 12:26 PM
Good ! First success ... :)
> Any ideas of what might be limiting this?
Still no statement : And short lines to card , cpu -- card : max. 50mm (otherwise...good luck. )
How long is distance cpu -- card ?
The cpu/sdmmc can work at 50M /4bit with sdcard - i have it here, running every day .
And only (!) use 1bit mode , until this working up to 50M without any problem.
2024-05-09 12:43 PM - edited 2024-05-09 12:57 PM
So the lines are only 45mm long, they are not shorted. There is a series resistor on all lines to help clean up the signal and pull up resistors to 3.3v on all lines except clk. I have an oscilloscope on the lines and the signals look clean coming across to the card
2024-05-09 01:03 PM
Ok,
so value of pullups, series r ?
And cpu port/speed setting ?