Skip to main content
Visitor II
August 8, 2024
Question

mmc deinit problem

  • August 8, 2024
  • 1 reply
  • 1025 views

Hi,

We are working on a low power application which uses an emmc memory. Now we have problem when Deinit mmc driver. When mmc is disabled we have a base consumption of XXuA (stop 2 power mode) but when it is needed mmc must be enabled (using Init functions from HAL) and then disabled again (using DeInit functions from HAL). after this process it is not possible to reach again XXuA, a 8mA are added to the base consumption. Is it needed to add some deinit function to the system or must we disable (forced) some clocks or internal supplies to asure de-initialization of mmc driver?

 

Thanks

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    August 12, 2024

    Welcome @cgamu, to the community!

    It would help potential helpers a little, if you could provide a few general conditions:

    • which MPU or MCU are you working with
    • what supply voltage does this device work with
    • what does your programme look like with which you switch the EMMC on and off

    Regards
    /Peter

    cgamuAuthor
    Visitor II
    August 19, 2024

    Hi @Peter BENSCH ,

    Thanks for your suggestions.

    MCU: STM32U585VIT6

    eMMC: ASFC4G31M-51BIN

    Supply: 3V

    Lines connected to uC:

    cgamu_0-1724055708705.png

    CODE:

    static RetVal_t SDMMC1_MMC_Init(void)
    {
     RetVal_t result = IDN_OK;
     hmmc1.Instance = SDMMC1;
     hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
     hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
     hmmc1.Init.BusWide = SDMMC_BUS_WIDE_8B;
     hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
     hmmc1.Init.ClockDiv = 2;
     if (HAL_MMC_Init(&hmmc1) != HAL_OK)
     {
     HAL_MMC_DeInit(&hmmc1);
     result = ERROR;
     initialized = FALSE;
     }
     else
     {
     initialized = TRUE;
     }
     return result;
    }
    
    RetVal_t SD_hm_init(void)
    {
     RetVal_t result = OK;
     hal_gpio_request_info_t gpio_info;
     gpio_info.port = PWR_FLASH_EN_Port;
     gpio_info.pin = PWR_FLASH_EN_Pin;
     gpio_info.mode = GPIO_MODE_OUTPUT_PP;
     gpio_info.pull = GPIO_NOPULL;
     GPIO_Request(&gpio_info);
     GPIO_WritePin(PWR_FLASH_EN_Port, PWR_FLASH_EN_Pin, GPIO_SET);
     if (SDMMC1_MMC_Init() != OK) {
     result = ERROR;
     }
     else
     {
     }
    
     HAL_MMC_CardInfoTypeDef mmc_info;
     HAL_MMC_GetCardInfo(&hmmc1, &mmc_info);
     sdmmc_info.BlockSize = mmc_info.BlockSize;
     sdmmc_info.NumBlocks = mmc_info.BlockNbr;
     return result;
    }
    
    RetVal_t SD_hm_deInit(void)
    {
     RetVal_t result = OK;
     HAL_MMC_DeInit(&hmmc1);
     HAL_GPIO_WritePin(PWR_FLASH_EN_Port, PWR_FLASH_EN_Pin, GPIO_RESET);
     HAL_GPIO_Release(PWR_FLASH_EN_Port, PWR_FLASH_EN_Pin);
     return result;
    }

    Hope this helps,