AnsweredAssumed Answered

STM32L1 cant enter lowpower sleep

Question asked by Jan Slavotínek on Jul 26, 2017
Latest reply on Jul 27, 2017 by Szymon Panecki

Hello everybody. 
I simply can not figure out the settings needed for lowpower sleep. I am aware of fact, that i need to enter lowpower run first. My setup:
- MSI 1048KHz

- PWR Reg Voltage Scale Scale 2

- TIM3 counter period 1048 (1ms) / TIM3 global interrupt enabled

- GPIO output PA4 (for debug pin toggle)

 

Unfortunately, my code goes into void HardFault_Handler(void) when i get to HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
What am I missing? with MAINREGULATOR_ON it works fine ... but thats not a lowpower sleep right?

 

CODE:

  /* USER CODE BEGIN 2 */
  HAL_TIM_Base_Start_IT(&htim3);
  HAL_Delay(500);
  HAL_PWREx_EnableLowPowerRunMode();
  while(__HAL_PWR_GET_FLAG(PWR_FLAG_REGLP) == RESET){
          HAL_Delay(1);
     }
  HAL_SuspendTick();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

  while (1)
  {
       HAL_GPIO_TogglePin(S1_GPIO_Port,S1_Pin);
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

       //enter sleep mode and wait for interrupt
       HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
//       HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
  }
  /* USER CODE END 3 */

Outcomes