4

I would like to put STM32F030K6T6 into STOP mode (low power mode), in which there should be current consumption around 5 μA.
But whatever I do the current consumption is around 450 μA in stop mode.
There is basically nothing else on the PCB, it's as simple as possible:
enter image description here

The board without MCU consumes 7 μA, that is quiescent current of LDO. So in the end I would expect to get 12 μA (7 + 5 μA).
When I place there MCU the consumption is around 2-3 mA in normal mode and 450 μA in stop mode.
All pins are set to analog input with no pull-ups, which is recommended config. All peripherals are disabled (like ADC, IWDG, I2C, SPI, timer, etc.). Only RTC is enabled.
I tried it with all pins set to output, it did not help either.

This is the code:

int main(void) {
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_RTC_Init();
    while (1) {
        goto_stop();
        HAL_Delay(3000); // 3 seconds of full power
    }
}
void goto_stop(void) {

    RTC_DateTypeDef sDate;
    sDate.Date=1;
    sDate.Month=RTC_MONTH_JANUARY;
    sDate.Year=22;
    sDate.WeekDay=RTC_WEEKDAY_MONDAY;
    //  HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD);

    if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)
    {
        /* Initialization Error */
        Error_Handler();
    }

    RTC_TimeTypeDef sTime;
    sTime.Seconds=0;
    sTime.Minutes=0;
    sTime.Hours=0;
    //    HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD);

    if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
    {
        /* Initialization Error */
        Error_Handler();
    }


    HAL_NVIC_EnableIRQ(RTC_IRQn);


    RTC_AlarmTypeDef sAlarm;
    sAlarm.Alarm=RTC_ALARM_A;
    sAlarm.AlarmTime.Seconds=20;
    sAlarm.AlarmTime.Minutes=0;
    sAlarm.AlarmTime.Hours=0;
    //  sAlarm.AlarmMask=RTC_ALARMMASK_SECONDS | RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_HOURS;
    sAlarm.AlarmMask=RTC_ALARMMASK_HOURS | RTC_ALARMMASK_DATEWEEKDAY;
    //  HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD);

    sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
    sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
    sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;

    if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
    {
        /* Initialization Error */
        Error_Handler();
    }


    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);


    __HAL_RCC_GPIOA_CLK_DISABLE();
    __HAL_RCC_GPIOB_CLK_DISABLE();
    __HAL_RCC_GPIOC_CLK_DISABLE();
    __HAL_RCC_GPIOD_CLK_DISABLE();
    __HAL_RCC_GPIOF_CLK_DISABLE();


    HAL_SuspendTick();

    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

    SystemClock_Config();

    HAL_ResumeTick();

}

What do I do wrong?

Chupacabras
  • 5,394
  • 2
  • 23
  • 50

1 Answers1

3

I put it aside for couple of days. Now I got back to it.

And it works OK without changing anything. 20 μA in stop mode (LDO + MCU), and 2.6 mA in run mode. When I flash firmware, disconnect SWD connector, push reset, it consumes 450 μA in stop mode.

I have to completely disconnect power, and connect back power, after that stop mode consumes 20 μA.

Then I found an option in flashing settings "Enable debug in low power modes" which is checked by default. I unchecked it and now it works even after flashing and I do not have to completely disconnect power.

enter image description here

Chupacabras
  • 5,394
  • 2
  • 23
  • 50