cancel
Showing results for 
Search instead for 
Did you mean: 

Low Power Mode in STM32WB

PRIYA_En
Associate

           I am using STM32WB for My Application, I want to initailly mcu is stop mode or sleep mode,when external interrupt (switch) is triggered its wakeup from low power mode.After wake up re-installize the System Clock for Mcu running configured clock frequency.

In my case its working well without configure STM32_WPAN (BLE) in STM32Cube Mx, When ever i use both Stop mode and BLE its not working while wakeup trigger is applied.

I tried all the ways of Sleep, Stop and Shutdown mode ,all are gives same response.I hope you understand my problem and give suggestion.

 

 

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();
  /* Config code for STM32_WPAN (HSE Tuning must be done before system clock configuration) */
  MX_APPE_Config();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

/* Configure the peripherals common clocks */
  PeriphCommonClock_Config();

  /* IPCC initialisation */
  MX_IPCC_Init();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_RTC_Init();
  MX_LPUART1_UART_Init();
  MX_TIM1_Init();
  MX_RF_Init();
  /* USER CODE BEGIN 2 */
  HAL_PWREx_EnterSHUTDOWNMode();
  SystemClock_Config();
  HAL_TIM_Base_Start_IT(&htim1);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	  if(gWakeupFlag==1)
	  {
		  if(gInitFlag==0)
		  {
			 MX_APPE_Init();
			 gInitFlag=1;
		  }
		 MX_APPE_Process();
	  }


    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

 

1 REPLY 1
FDumontKeller
Associate III

Hi @PRIYA_En,

I had a similar missunderstanding when it came to use the of low power modes while the BLE is been used.

When you use the framework provided by CubeMX, a low power manager is already implemented and each time the function "void MX_APPE_Process(void)"  is executed, it will check for the posibility of going into a low power mode.

The sequencer will check if there are any tasks to be done. If there is nothing to do, the UTIL_SEQ_Idle() will make the MCU go into one of the allowed power modes (either sleep mode or stop2, which are the only ones allowed by the current low power management generated by the CubeMX). 

Now this also means that each advertising event of the radio module, generates an interrupt that will wake up the MCU and the sequencer will check again if there is somehthing to be done. If nothing is pending, it will go back to a low power mode. For example in the image below each spike of current is when an advertising event happend and the MCU had to wake up. During those 1s time is when the MCU was doing something an could go to a low power mode.

image2024-3-27_15-56-24.png

if you really want to stay in a low power mode for a prolonged time and only be woken up by a switch, then you need to disable the advertising. Like in the example below: 

 

image2024-3-28_9-26-41.png

I hope this helps and here (AN5289 , item 4.6) is a description of what the Low power manager does in the STM32WB framework.

Best Regards.