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:
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?