2025-12-02 2:04 AM
Hi,
I am currently working on the firmware of a PCB with an STM32G031K8T6 as the MCU, supplied by a 1.8V voltage.
When I enter Stop 1 mode, the consumption of the MCU drops to 100uA, instead of the 7uA stated in the datasheet.
The app_stop function is as follows :
void app_stop(void)
{
timer_uninit();
i2c_slave_uninit();
i2c_master_uninit();
gpio_stop_mode();
HAL_SuspendTick();
SystemClock_Config_StopMode();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
}
void gpio_stop_mode(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_All;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_All;
GPIO_InitStruct.Pin &= ~(GPIO_WAKEUP_PIN);
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
}
uint8_t timer_uninit(void)
{
timer_off();
return HAL_TIM_Base_DeInit(&timer_handler);
}
uint8_t timer_off(void)
{
if(timer_handler.Instance != 0)
{
int irq_status = (timer_handler.Instance->DIER & TIM_IT_UPDATE) ? 1 : 0;
HAL_TIM_Base_Stop_IT(&timer_handler);
return irq_status;
}
return 0;
}
uint8_t i2c_slave_uninit(void)
{
return HAL_I2C_DeInit(&i2c_slave_handler);
}
uint8_t i2c_master_uninit(void)
{
return HAL_I2C_DeInit(&i2c_master_handler);
}
void SystemClock_Config_StopMode(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
//RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_LSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
}
I checked all the IO levels, non of them are drawing current through a pull resistor.The SWD probe is removed.
Could you please tell me what I am missing ?
Best regards,
2025-12-09 1:26 AM
Hi Gyessine,
Sorry for my late reply.
I made a new projects with the following code in main.c, the consumption of the STM32 remains the same (~97uA).
int main(void)
{
// Reset of all peripherals, initializes flash interface and systicks
HAL_Init();
// Configure the system clock to 48 MHz
SystemClock_Config();
/* Infinite loop */
while(1)
{
HAL_Delay(1000);
HAL_SuspendTick();
SystemClock_Config_StopMode();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();
}
}The System_Clock_Config_StopMode function is as follows :
void SystemClock_Config_StopMode(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
//RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_LSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
}So I guess it seems to be HW related ?
Best regards,
2025-12-09 1:37 AM
Hi Shirley,
I tried the Standby mode, which gives the same current consumption (97uA), here is my main function :
int main(void)
{
// Reset of all peripherals, initializes flash interface and systicks
HAL_Init();
// Configure the system clock to 48 MHz
SystemClock_Config();
/* Infinite loop */
while(1)
{
HAL_Delay(1000);
HAL_SuspendTick();
SystemClock_Config_StopMode();
HAL_PWR_EnterSTANDBYMode();
HAL_ResumeTick();
}
}
2025-12-09 1:50 AM
hello @levantg
well, in that case, it really looks like a hardware related issue
just to be safe, verify that no interrupts are preventing the STM32 from entering low-power modes.
Double-check the NVIC configuration. If no issues are found, proceed to inspect the hardware.
We hope this analysis helped you identify the root cause of your issue.
Gyessine
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-12-09 7:38 AM - edited 2025-12-09 7:43 AM
From where you have info you need
SystemClock_Config_StopMode();
Mode is name STOP because system clock is stopped = no require any change from HSI !.
2025-12-09 8:00 AM
I just tried it to make sure the problem did not come from a clock issue. But even when I don't use this functions the consumption does not decrease.
2025-12-09 8:02 AM
I used __disable_irq function before entering stop mode, but it does not change anything.
I cut all the tracks going to the STM32 except for the SWD and the power supply, I also removed all external pull resistors and bypass capacitors. Despite this the consumption of the STM32 remains around 100uA...
Is there any other lead I could investigate ?
levantg
2025-12-09 9:47 AM
Primary good practice is toggle pin or led after wake to check if MCU real stops.
int main(void)
{
// Reset of all peripherals, initializes flash interface and systicks
HAL_Init();
// Configure the system clock to 48 MHz
SystemClock_Config();
/* Infinite loop */
while(1)
{
HAL_Delay(1000);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_GPIO_Toggle....
}
}but here nobody knows wake source plus no gpio init ...
2025-12-10 8:40 AM
Hi,
I tried to toggle an IO like you advised, and the IO does not toggle on the PCB, so it seems the STM32 is in STOP mode, here is the code :
void gpio_init_debug(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
if(!__HAL_RCC_GPIOC_IS_CLK_ENABLED())
{
__HAL_RCC_GPIOC_CLK_ENABLE();
}
/*Configure GPIO pin as output : PC6 */
GPIO_InitStruct.Pin = GPIO_DEBUG_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIO_DEBUG_PORT, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIO_DEBUG_PORT, GPIO_DEBUG_PIN, GPIO_PIN_RESET);
}
int main(void)
{
// Reset of all peripherals, initializes flash interface and systicks
HAL_Init();
// Configure the system clock to 48 MHz
SystemClock_Config();
gpio_init_debug();
/* Infinite loop */
while(1)
{
HAL_Delay(1000);
HAL_SuspendTick();
__disable_irq();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_GPIO_TogglePin(GPIO_DEBUG_PORT, GPIO_DEBUG_PIN);
HAL_ResumeTick();
}
}
2025-12-11 12:29 AM
hello @levantg
Can you test the consumption of the boards in normal mode and then in various other low-power modes, such as:
I am particularly interested in understanding if there even a decrease in consumption from normal mode to low-power modes, and between different low-power modes, especially the lightest ones like low-power run and sleep modes.
If all tests result in the same 100 µA consumption, and since you mentioned that the LED does not toggle, this strongly suggests verifying the measurement method. How are you measuring the consumption?
Here is a hardware implementation example of an IDD jumper from U083 (jumper 5).
Gyessine
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-12-11 7:35 AM
Show your schematics how you create 1,8V and other power parts. For example Image from @Gyessine have R25,27 and this create passive current 53uA...