cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WL3R high current consumtion in deep stop

sbelcatronic
Associate III

Hello,

On the STM32WL3R microcontroller, when deep stop mode is activated, the current consumption is about 1.3 mA, which is a very high value compared to the 0.8 µA specified in the datasheet. In contrast, when I activate shutdown mode in the same firmware, I measure the correct current consumption of about 14 nA.

This is the code used to enter deep stop mode:

static void EnterDeepStop(void)
{
	__HAL_MRSUBG_STROBE_CMD(CMD_SABORT);
	HAL_MRSubG_MspDeInit();	//deinizializza il modulo radio
	HAL_TIM_Base_DeInit(&htim2);
	HAL_SuspendTick();

	HAL_PWREx_DisableDEEPSTOP2();
	//HAL_PWREx_EnableDEEPSTOP2();

	ConfigureGPIOForStop();
	//LL_PWR_DisableBORinSDN();

	HAL_PWREx_DisableGPIOPullUp(PWR_WAKEUP_PORTB,
								PWR_GPIO_BIT_13|
								PWR_GPIO_BIT_14);

	HAL_PWREx_EnableGPIORetention();	//abilia GPIO retenction
	HAL_PWREx_DisableSRAMRetention();

	HAL_PWREx_GetClearInternalWakeUpLine();

	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PORTA,
							PWR_WAKEUP_PIN0|PWR_WAKEUP_PIN8|PWR_WAKEUP_PIN9|PWR_WAKEUP_PIN11,
							PWR_WUP_FALLEDG );
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PORTA,
							PWR_WAKEUP_PIN0|PWR_WAKEUP_PIN8|PWR_WAKEUP_PIN9|PWR_WAKEUP_PIN11,
							PWR_WUP_RISIEDG );

	//__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF_ALL);
	__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFA0|PWR_FLAG_WUFA8|PWR_FLAG_WUFA9|PWR_FLAG_WUFA11);


	sConfigDEEPSTOP.deepStopMode = PWR_DEEPSTOP_WITH_SLOW_CLOCK_ON;
	HAL_PWR_ConfigDEEPSTOP(&sConfigDEEPSTOP);

	HAL_PWR_EnterDEEPSTOPMode();

	while(1);

}

in function ConfigureGPIOForStop(); I reconfigure the I/O pin for reduce currente consuptio (I set all the PIN in Analog and activate Pull up resistor as requared in my hardware.  

void ConfigureGPIOForStop(void)
{
	GPIO_InitTypeDef GPIO_InitStruct = {0};

	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();

	GPIO_InitStruct.Pin = TP1_Pin| GPIO_PIN_2 | GPIO_PIN_3| // SWDIO, SWCLK
			GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10 |
			GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

//	GPIO_InitStruct.Pin = TP1_Pin;
//	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
//	GPIO_InitStruct.Pull = GPIO_NOPULL;
//	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = TP2_Pin|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|
			GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|
			GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

//	GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_12;
//	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
//	GPIO_InitStruct.Pull = GPIO_PULLUP;
//	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

	HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A,
	                         PWR_GPIO_BIT_0|
							 //PWR_GPIO_BIT_1|
							 //PWR_GPIO_BIT_2|
							 //PWR_GPIO_BIT_3|
							 //PWR_GPIO_BIT_4|
							 //PWR_GPIO_BIT_5|
							 //PWR_GPIO_BIT_6|
	                         //PWR_GPIO_BIT_7|
	                         PWR_GPIO_BIT_8|
	                         PWR_GPIO_BIT_9|
							 //PWR_GPIO_BIT_10|
	                         PWR_GPIO_BIT_11
							 //PWR_GPIO_BIT_12|
							 //PWR_GPIO_BIT_13|
	                         //PWR_GPIO_BIT_14|
	                         //PWR_GPIO_BIT_15
							 );
	    HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_A,
	    					 PWR_GPIO_BIT_0|
							 PWR_GPIO_BIT_1|
							 PWR_GPIO_BIT_2|
							 PWR_GPIO_BIT_3|
							 PWR_GPIO_BIT_4|
							 PWR_GPIO_BIT_5|
							 PWR_GPIO_BIT_6|
							 PWR_GPIO_BIT_7|
							 PWR_GPIO_BIT_8|
							 PWR_GPIO_BIT_9|
							 PWR_GPIO_BIT_10|
							 PWR_GPIO_BIT_11|
							 PWR_GPIO_BIT_12|
							 PWR_GPIO_BIT_13|
							 PWR_GPIO_BIT_14|
							 PWR_GPIO_BIT_15
							);
	    HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_B,
	    					 PWR_GPIO_BIT_0|
							 PWR_GPIO_BIT_1|
							 PWR_GPIO_BIT_2|
							 PWR_GPIO_BIT_3|
							 PWR_GPIO_BIT_4|
							 PWR_GPIO_BIT_5|
							 PWR_GPIO_BIT_6|
							 PWR_GPIO_BIT_7|
							 PWR_GPIO_BIT_8|
							 PWR_GPIO_BIT_9|
							 PWR_GPIO_BIT_10|
							 PWR_GPIO_BIT_11|
							 PWR_GPIO_BIT_12|
							 PWR_GPIO_BIT_13|
							 PWR_GPIO_BIT_14|
							 PWR_GPIO_BIT_15
							 );
	    HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_B,
	    					 //PWR_GPIO_BIT_0|
							 //PWR_GPIO_BIT_1|
							 //PWR_GPIO_BIT_2|
							 //PWR_GPIO_BIT_3|
							 //PWR_GPIO_BIT_4|
							 //PWR_GPIO_BIT_5|
							 PWR_GPIO_BIT_6|
							 //PWR_GPIO_BIT_7|
							 //PWR_GPIO_BIT_8|
							 //PWR_GPIO_BIT_9|
							 //PWR_GPIO_BIT_10|
							 //PWR_GPIO_BIT_11|
							 PWR_GPIO_BIT_12
							 //PWR_GPIO_BIT_13|
							 //PWR_GPIO_BIT_14
							 //PWR_GPIO_BIT_15
							 );
}

The deep stop mode lock work properly and the microcontroller wakeup from pins as I expected.

Any suggestions to solve this problem?

Best regards,

 

1 REPLY 1
Gyessine
ST Employee

Hello @sbelcatronic 
Just to be sure, did you at any time tried to start a debug session in the project?
If so, manually clear the low-power-mode debug bits before entering deep-stop mode. This condition might be the root cause of the issue.

  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);

and ensure to disable debug in low power modes option in debug configuration.

Gyessine_0-1780648466128.png

BR
Gyessine 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.