2026-05-22 2:55 AM
I am having difficulties with initializing a SD Card.
I am making use of the generated code to initialize the card:
void MX_SDMMC1_SD_Init(void) I measured with a scope and I am getting 400KHz clock. All the pull-up resistors are correct and voltage is correct.
Within the SD_PowerON() function, the function to send the MD8: SEND_IF_COND is called, but I get no response from the card. HAL Error Return is timeout.
I tried a differ SD Card as well.
Any suggestions where to start checking for potential issues?
static uint32_t SD_PowerON(SD_HandleTypeDef *hsd)
{
__IO uint32_t count = 0U;
uint32_t response = 0U;
uint32_t validvoltage = 0U;
uint32_t errorstate =0U;
#if (USE_SD_TRANSCEIVER != 0U)
uint32_t tickstart = HAL_GetTick();
#endif /* USE_SD_TRANSCEIVER */
/* CMD0: GO_IDLE_STATE */
errorstate = SDMMC_CmdGoIdleState(hsd->Instance);
if (errorstate != HAL_SD_ERROR_NONE)
{
return errorstate;
}
/* CMD8: SEND_IF_COND: Command available only on V2.0 cards */
errorstate = SDMMC_CmdOperCond(hsd->Instance);
if (errorstate == SDMMC_ERROR_TIMEOUT) /* No response to CMD8 */
{
hsd->SdCard.CardVersion = CARD_V1_X;
/* CMD0: GO_IDLE_STATE */
errorstate = SDMMC_CmdGoIdleState(hsd->Instance);
if (errorstate != HAL_SD_ERROR_NONE)
{
return errorstate;
}