we have an application that requires powering an eMMC down and then back up while the MCU keeps running.
We're successfully using the eMMC connected to the SDMMC1 peripheral running on a 25MHz 8-bit bus, with ClockPowerSave ENABLED. In this configuration the eMMC will not restart because it doesn't get the required 74 clocks that are part of the initialization, and simply does not respond to the first command (there are only 4 or 5 clocks before CMD starts to toggle):
One solution was to run with ClockPowerSave DISABLED, but that came at the cost of a power increase of some 18mW, which in this application is not acceptable.
Another solution that we came upon, is to run with ClockPowerSave ENABLED, but to disable it
hmmc->Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; SDMMC_Init(hmmc->Instance, hmmc->Init);
just before shutting down the eMMC with HAL_MMC_DeInit(), and then to re-enable it after HAL_MMC_Init():
hmmc->Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_ENABLE; HAL_MMC_ConfigWideBusOperation(hmmc, SDMMC_BUS_WIDE_8B);
On restart, the 74 clocks (or at least, most of them) come at 25MHz before HAL_MMC_Init() slows the bus down to the 200kHz initialization speed:
Given that eMMCs are not made to be hot swappable, is this a reliable way to stop and restart the device? Is there a better way?
Thank you for your reply.
It turns out that the silicon is designed to only produce the 74 clocks once ... when the SDMMC peripheral's Power Control Register's PWRCTRL bits are set to "Power-on" ... fair enough, the eMMC is not expected to be power cycled independently of the MCU.
So the solution was to generate those 74 clocks ourselves, by manipulating the GPIO directly.