2025-02-10 07:17 PM - edited 2025-02-10 08: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!