Skip to main content
Associate
December 2, 2025
Solved

STM32G031K8 consumes 100uA in Stop1 mode

  • December 2, 2025
  • 11 replies
  • 6049 views

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,

Best answer by Gyessine

hello @levantg 
After further investigation, the problem appears to be related to the SysTick itself, and not to the low-power mode.
Using LSI results in a low value in the STK_RVR register (0x1F), which causes the microcontroller to get stuck in the SysTick handler and prevents it from performing other tasks.
The solution is to reduce the SysTick frequency from 1 kHz to 100 Hz by adding the following code in place of the existing code in stm32g0xx_hal.c:

//HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_100HZ;

//instead of
HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT;

or just pick another timebase instead of systick like TIM1 using cubeMX
here I attached a project that can help you just add low power functionalities to it
Hope that helps you solve your issue
Gyessine

11 replies

January 13, 2026

Modded Games Continue to Gain Popularity Among Gamers

Modded games are becoming increasingly popular among both mobile and PC gamers. Players are drawn to mods because they offer enhanced features such as unlocked content, improved gameplay mechanics, and reduced grind. These modifications allow users to enjoy games with more freedom and flexibility.

Simulation games, especially farming and management titles, benefit greatly from modding communities. Mods help streamline repetitive tasks while keeping gameplay engaging and enjoyable. As a result, many players actively seek trusted platforms for guides and mod-related content.

For those interested in farming simulation mods and gaming resources, useful information can be found at FM23Mod

As gaming communities continue to grow, modding remains an important part of how players customize and enjoy their gaming experiences.