cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L431 consumes more than expected at low power mode.

NEdom.1
Associate III

Hi, I am developing a low power application using STM32L431RCTx of 64-pin QFTP package.

I have gone through the manual and some web content and tried several methods. The minimum current consumption I could achieve is 1.33mA at 3.6V power supply. 

NEdom1_11-1739243694695.jpeg

The system uses two ER34615 batteries in parallel for power supply. I have two TPS631010 chips working at 3.3V for the MCU and RF, 5V for the sensor circuit respectively.

The MCU uses 8MHz and 32.768k as external HSI and LSI clock respectively. The MCU works at 2MHz.

Here is the CubeMX configuration.

NEdom1_1-1739241627290.png

The code for entering standby mode:

 

 

	/* Enable the WAKEUP PIN */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH);

	/* Finally enter the standby mode */
	HAL_PWR_EnterSTANDBYMode();

 

 

The possible looping circuit that might consume power:

The battery block

NEdom1_2-1739241942059.png

The 3.3V and 5V block

NEdom1_3-1739241971073.png

The MCU reset circuit

NEdom1_4-1739242364188.png

The 485 transceiver circuit. The 5V is turned on only at the time of reading sensors. 

NEdom1_5-1739242409933.png

We also use some DIP switches to set up the address of the device.

NEdom1_6-1739242847027.png

The LED circuit with PWM as indicator.

NEdom1_7-1739242923760.png

The WAKUP circuit with a button key.

NEdom1_8-1739242953237.png

SWD circuit for downloading code to the MCU.

NEdom1_9-1739243052511.png

 

The RF module works at 3.3V. It has a low power mode and works good. The system consumes 1.33mA with or without the RF module.

NEdom1_10-1739243582072.png

 

Before going to sleep, I have down the following. Honestly, it seems the code does not work or I am not doing it right. The current consumption stays the same after adding these de-init code.

 

 

void GPIO_Deinit(void){
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  // DIP address coding
  HAL_GPIO_DeInit(GPIOC, LBIT0_Pin|LBIT1_Pin|LBIT2_Pin|LBIT3_Pin);
  HAL_GPIO_DeInit(GPIOB, CBIT0_Pin|CBIT1_Pin|CBIT2_Pin|CBIT3_Pin
      |CBIT4_Pin|CBIT5_Pin|CBIT6_Pin|CBIT7_Pin);

  /*Configure GPIO pins : CBIT0_Pin CBIT1_Pin CBIT2_Pin CBIT3_Pin
                           CBIT4_Pin CBIT5_Pin CBIT6_Pin CBIT7_Pin */
  GPIO_InitStruct.Pin = CBIT0_Pin|CBIT1_Pin|CBIT2_Pin|CBIT3_Pin
                          |CBIT4_Pin|CBIT5_Pin|CBIT6_Pin|CBIT7_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /*Configure GPIO pins : LBIT0_Pin LBIT1_Pin LBIT2_Pin LBIT3_Pin */
  GPIO_InitStruct.Pin = LBIT0_Pin|LBIT1_Pin|LBIT2_Pin|LBIT3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOH_CLK_DISABLE();
  __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();
}

void go_standby_mode(void) {
	/* Disable debug and trace in low-power modes */
	HAL_DBGMCU_DisableDBGSleepMode();
	HAL_DBGMCU_DisableDBGStopMode();
	HAL_DBGMCU_DisableDBGStandbyMode();

	/** display  the string **/
	printf("About to enter the STANDBY MODE\r\n");
	sensor_pwr_off();
	lora_a39c_set_sleep_mode();
	/* one last string to be sure */
	printf("STANDBY MODE is ON\r\n");

	HAL_TIM_Base_MspDeInit(&htim1);
//	HAL_RTC_MspDeInit(&hrtc);
	HAL_ADC_MspDeInit(&hadc1);

	HAL_CRC_MspDeInit(&hcrc);
	HAL_UART_MspDeInit(&huart2);
	HAL_UART_MspDeInit(&huart1);
	HAL_UART_MspDeInit(&hlpuart1);

/* PWR control */
  HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_C, PWR_GPIO_BIT_2 | PWR_GPIO_BIT_3 | PWR_GPIO_BIT_13);
  HAL_PWREx_EnablePullUpPullDownConfig();

/* 485UART PU */
  HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_2 | PWR_GPIO_BIT_3);
    HAL_PWREx_EnablePullUpPullDownConfig();
/*LoRa control */
  HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_11 | PWR_GPIO_BIT_12);
  HAL_PWREx_EnablePullUpPullDownConfig();

	/* De-init the GPIOS */
	GPIO_Deinit();

	/* Enable the WAKEUP PIN */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH);

	/* Finally enter the standby mode */
	HAL_PWR_EnterSTANDBYMode();
}

 

 

 

 

 

Thanks for your kindly help!

4 REPLIES 4
Sarra.S
ST Employee

Hello @NEdom.1

Make sure the low power modes' debug options are off. The debug module and some internal clocks can remain active during low-power modes, you can disable these options by clearing the debug bits in the DBG_CR register, check this article: Increased consumption in low power modes - STMicroelectronics Community 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


@Sarra.S wrote:

Make sure the low power modes' debug options are off. 


+1

@NEdom.1 also ensure that the debugger is physically disconnected - otherwise you will get leakage into the connection.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Thank you Sarra. Should I clear the debug bits right before going to sleep, or just the moment after a wakeup-reset cycle?

I have already put the code at the beginning of the low power function.

 

	/* Disable debug and trace in low-power modes */
	HAL_DBGMCU_DisableDBGSleepMode();
	HAL_DBGMCU_DisableDBGStopMode();
	HAL_DBGMCU_DisableDBGStandbyMode();

 

Where the three methods generated by ST IDE.

 

/**
  * @brief  Disable the Debug Module during STOP0/STOP1/STOP2 modes.
  * @retval None
  */
void HAL_DBGMCU_DisableDBGStopMode(void)
{
  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
}

/**
  * @brief  Enable the Debug Module during STANDBY mode.
  * @retval None
  */
void HAL_DBGMCU_EnableDBGStandbyMode(void)
{
  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
}

/**
  * @brief  Disable the Debug Module during STANDBY mode.
  * @retval None
  */
void HAL_DBGMCU_DisableDBGStandbyMode(void)
{
  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
}

 

Tried adding the DBGMCU bits macros to disable debug options but no effect in decreasing the power consumption.

YES. I have already disconnected the SWD debug pins. Thank you for reminding.