# STM32 standby mode power consumption is too high

I'm experimenting with standby mode on STM32F407VGT6. I know how to put MCU into standby mode(or I think to know that). I'm doing that with this init function:

void MX_RTC_Init(void) {

RTC_TimeTypeDef sTime = {0};
RTC_DateTypeDef sDate = {0};

/** Initialize RTC Only  */   hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv =127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_WAKEUP;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK)   {
Error_Handler();
}

/** Initialize RTC and set the Time and Date */
sTime.Hours = 0x13;
sTime.Minutes = 0x20;
sTime.Seconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
sDate.WeekDay = RTC_WEEKDAY_THURSDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x30;
sDate.Year = 0x20;

if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);


}

This init function allows to wake up MCU from standby mode with wakeup pin(PA0) and with timer(currently period is ~20sec). Next function is called when I want to put MCU into standby mode:

void Enter_StandbyMode(void)
{
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 40960,RTC_WAKEUPCLOCK_RTCCLK_DIV16);

HAL_PWR_EnterSTANDBYMode();


}

Again this works as I expect(I used diode to indicate when MCU wake-up from standby) but my question is next one:

Why I still have voltage on pins when MCU is in standby mode? And when I use multimeter to measure current I got ~30mA power consumption in normal mode(when MCU isn't in standby mode) and ~0.58mA(which is ~580uA) when MCU is in standby mode. I read in datasheet that MCU in standby mode can have power consumption less then 5uA. Every hint and idea are welcome

• What other components are on the board that might have a quiescent current? Or are you measuring directly the current to the MCU? – Maximilian Gerhardt Feb 12 at 11:10
• I measure current on JP1, Idd pins (datasheet says that we can take off jumper on Idd pins and then we can connect multimeter to measure current [st.com/content/ccc/resource/technical/document/application_note/… page 20). On MCU i have usb-uart board and just rx/tx pins and gnd are connected to MCU, one adc, 5v is used from mcu for supplying LCD, sim800l is connected to MCu via Rx/Tx pins and gnd – subavet995 Feb 12 at 11:38
• "one adc" Is there a potentiometer, by any chance? "I still have voltage on pins" which pins? – Maple Feb 12 at 13:02
• On pins which I configurate for utilization (5V, 3V, Tx pin,..). No there isn't any potentiometer. – subavet995 Feb 12 at 13:43
• Your link goes nowhere, and you are referring to a jumper, but have only specified a microcontroller - you need to specify what board you are using if it is COTS. The USB/Serial bridge is a microprocessor as is the sim800l , they will draw current too. They may have low power modes you can put them in. – Clifford Feb 12 at 17:35

Have you enabled the Clock for the Power Module? It is kind of confusing that you have to enable something to reduce the power consumption.

Deactivating all clocks of unused Peripherals will also lead to a major power reduction. We also measure higher current consumption while the controller is still connected to a debugger.

• I didn't find something like that. I try with this to reduce power consumption: __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOE_CLK_DISABLE(); This thing is only what I find which looks like clock for power module:__HAL_RCC_PWR_CLK_SLEEP_ENABLE(); I got same power sonsumption. – subavet995 Feb 13 at 10:15
• My bad, was not paying attention to your controller family. In STM32L4 family the function name is __HAL_RCC_PWR_CLK_ENABLE. For F0 family your solution might be correct. – A.R.C. Feb 13 at 15:07

Hopefully it isn't too late to answer this. You should configure all unused GPIO pins to GPIO_MODE_ANALOG and GPIO_NOPULL. If you need GPIO output pins configured on the STM32, you should use the lowest GPIO frequency speed, preferably GPIO_SPEED_FREQ_LOW.

Reducing SYSCLK clock speeds, along with other bus clock speeds such as HCLK (AHB bus clock), PCLK1 (APB1 bus clock), PCLK2 (APB2 bus clock) by increasing their prescalers should also reduce power consumption.

I do not know if you are using other peripherals such as SPI, DAC/ADC, I2C, but if you do have them, they contribute to the microcontroller's power consumption too.

Check this link here, the tricks listed above can be found on page 10 of that link. Although the link provides tricks for the STM32F3, some of the tricks listed there are still applicable for the STM32F4.