Question
very slowly initialisation of SD
Code generated by CubeMX
static void MX_SDMMC1_SD_Init(void)
{
/* USER CODE BEGIN SDMMC1_Init 0 */
/* USER CODE END SDMMC1_Init 0 */
/* USER CODE BEGIN SDMMC1_Init 1 */
/* USER CODE END SDMMC1_Init 1 */
hsd1.Instance = SDMMC1;
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
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;
HAL_SD_Init(&hsd1);
/* USER CODE BEGIN SDMMC1_Init 2 */
BSP_SD_Init();
HAL_Delay(200);
/* USER CODE END SDMMC1_Init 2 */
}There is a function in - SDMMC_GetCmdResp1(SD MMC x, SD MMC_CMD_UP_CMD, SD MMC_CMD TIMEOUT);
When the Sdmmc->STA register is checked in the body of this function, the check takes a very long time, since the CMDACT bit is in one. After 20-30 seconds, the bit is reset and the card works perfectly. Tellingly, the initialization time may be shorter, sometimes everything passes at once.
4-bit mode, 48 MHz frequency.
How to fix?
