2025-02-10 7:17 PM - edited 2025-02-10 8:02 PM
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.
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.
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
The 3.3V and 5V block
The MCU reset circuit
The 485 transceiver circuit. The 5V is turned on only at the time of reading sensors.
We also use some DIP switches to set up the address of the device.
The LED circuit with PWM as indicator.
The WAKUP circuit with a button key.
SWD circuit for downloading code to the MCU.
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.
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!
2025-03-03 1:25 AM
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.
2025-03-03 1:35 AM
@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.
2025-03-06 12:02 AM - edited 2025-03-07 2:58 AM
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.
2025-03-06 12:03 AM - edited 2025-03-06 1:57 AM
YES. I have already disconnected the SWD debug pins. Thank you for reminding.