cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected extra 1.5uA after first wakeup from stop mode STM32L0

Leo Korbee
Associate II

I'm testing STM32L051C8T6 without any peripherals or extra electronics. No crystals used.

After reset and first power down I get about 1.40uA. the MCU wakes up and powers down and then I get about 3uA in power down mode. After changing all kind of code I'm out of options. Any suggestions?

The main code. The MCU wakes up from RTC AlarmA.

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
//  MX_RTC_Init();
  /* USER CODE BEGIN 2 */
  __HAL_RCC_PWR_CLK_ENABLE();
  HAL_PWR_EnableBkUpAccess();
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, 1);
	HAL_Delay(1000);
	//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, 0);
	HAL_Delay(100);
 
	// reset_RTC; //change time to 0:00:00
	MX_RTC_Init();
 
	HAL_PWREx_EnableUltraLowPower();
	// USR_PowerDown_GPIO();
	HAL_SuspendTick();
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
	// rest system clock config
	SystemClock_Config();
	HAL_ResumeTick();
 
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

1 ACCEPTED SOLUTION

Accepted Solutions
Leo Korbee
Associate II

Sorry, I did not read the doc leading the HAL_PWR_EnterSTOPMode function.

I had to add __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); before starting the HAL_PWR_EnterSTOPMode....

 * @note Before entering in this function, it is important to ensure that the WUF
 *       wakeup flag is cleared. To perform this action, it is possible to call the
 *       following macro : __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU)

This solved my problem:

        __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
	SystemClock_Config();
	HAL_ResumeTick();

View solution in original post

1 REPLY 1
Leo Korbee
Associate II

Sorry, I did not read the doc leading the HAL_PWR_EnterSTOPMode function.

I had to add __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); before starting the HAL_PWR_EnterSTOPMode....

 * @note Before entering in this function, it is important to ensure that the WUF
 *       wakeup flag is cleared. To perform this action, it is possible to call the
 *       following macro : __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU)

This solved my problem:

        __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
	SystemClock_Config();
	HAL_ResumeTick();