Hello,
I am using STM32G4 to develop a project where I am running FreeRTOS.
Recently I was working on debugging the issues for low power mode.
I can confirm all the peripherals clocks are disabled before entering the STOP1 mode, but the power consumption is still very high (~35mA).
My function to prepare for STOP1 mode is here:
void EnterStop1Mode(void)
{
/* Ensure all tasks are idle before entering Stop mode */
taskENTER_CRITICAL();
//HAL_PWREx_EnableLowPowerRunMode();
/* Disable SysTick Completely */
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
HAL_SuspendTick();
/* Disable Peripheral Clocks to Reduce Power */
HighPowerSwitch(SWITCH_OFF);
HAL_ADC_MspDeInit(&hadc1);
HAL_SPI_MspDeInit(&hspi1);
HAL_SPI_MspDeInit(&hspi2);
HAL_TIM_PWM_MspDeInit(&htim1);
HAL_TIM_PWM_MspDeInit(&htim2);
HAL_TIM_PWM_MspDeInit(&htim15);
HAL_TIM_Encoder_MspDeInit(&htim3);
HAL_TIM_Encoder_MspDeInit(&htim4);
HAL_UART_MspDeInit(&huart1);
HAL_I2C_MspDeInit(&hi2c2);
HAL_DAC_MspDeInit(&hdac1);
/* Disable Debug Mode to Allow Full Power Down */
//HAL_DBGMCU_DisableDBGStopMode();
PreStop_SystemClock_Config();
HAL_PWREx_EnableLowPowerRunMode(); // Enable low-power regulator
/* Enter Stop 1 Mode */
HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
/* --- Wake-Up Occurred --- */
/* Restore System Clock */
SystemClock_Config();
/* Re-enable SysTick */
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
HAL_ResumeTick();
/* Restore GPIOs */
MX_GPIO_Init();
/* Resume FreeRTOS Task Scheduling */
taskEXIT_CRITICAL();
}
I tried with the code like below:
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
HAL_Delay(1000);
/* Enter Stop 1 Mode */
HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
while (1);
}
just to test if it might be because of any peripherals not properly disabled. However running this code gives the me same result.
Do you see anything I made is fundamentally incorrect? I tried to find a standard procedure for entering the low power mode, but couldn't find any. Would you suggest some different approaches I could maybe check it out?
One thing worth to mention is, when I had a fresh PCB without any program, the power consumption is close to zero. Thus, I can be sure, I don't have anywhere in hardware it is leaking the current.
Thanks for your support!