cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 - Sending CMD5 to eMMC card

CDiaz.2
Associate II

Hi,

I'm working with an STM32H7 connected though SDMM1 (1bit bus width) with an eMMC, I need to put the eMMC into sleep mode so we can reduce the power consumption when it is not being used.

According to the information I've been able to find we need to send the CMD5 with the 15bit set to 1 so the card will trigger the transition into sleep state. To get the eMMC card back into standby mode I need to send the CMD5 with the 15bit set to 0.

It's the first time I've been able to use such devices, I would like to validate the following code snippet corresponds to the description above.

/* NOTE:
 * rca is the card Relative Card Address obtained using the HAL_MMC_GetCardInfo API.
 */
void eMMC_Sleep(void)
{
	SDMMC_CmdInitTypeDef cmd = {
		.CmdIndex = SDMMC_CMD_SDMMC_SEN_OP_COND,
		.Argument =  (rca << 16) | (1 << 15),
 
		.Response = SDMMC_RESPONSE_SHORT,
		.WaitForInterrupt = SDMMC_WAIT_NO,
		.CPSM = SDMMC_CPSM_ENABLE
	};
 
	(void) SDMMC_SendCommand(&hmmc1, &cmd);
 
	/* Check for error conditions */
	SDMMC_GetCmdResp1(SDMMCx, SDMMC_CMD_SDMMC_SEN_OP_COND, 1000 * 2);
}
 
void eMMC_Wakeup(void)
{
	SDMMC_CmdInitTypeDef cmd = {
		.CmdIndex = SDMMC_CMD_SDMMC_SEN_OP_COND,
		.Argument =  (rca << 16),
 
		.Response = SDMMC_RESPONSE_SHORT,
		.WaitForInterrupt = SDMMC_WAIT_NO,
		.CPSM = SDMMC_CPSM_ENABLE
	};
 
	(void) SDMMC_SendCommand(&hmmc1, &cmd);
 
	/* Check for error conditions */
	SDMMC_GetCmdResp1(SDMMCx, SDMMC_CMD_SDMMC_SEN_OP_COND, 1000 * 2);
}

Any tips are welcome.

Regards

1 REPLY 1
PMera.1
Associate II

Hi. Did you manage to get it working?