cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB5MMGH6 consuming to much current at Stop 2 Mode

MLuis.1
Associate III

I'm using an STM32WB5MMGH6 and it's consuming too much current at Stop 2 Mode.

The existing BLE connections are closed and advertising is stopped. All unnecessary peripherals, gpios and interrupts are disabled. The system clock is changed to MSI at 1MHz and Systick is disabled.

In the current conditions, the system consumes about 1 mA while in Stop Mode 2.

We tried using Shutdown Mode and got a consumption of about 100 uA which corresponds to the expected current bleed eliminating a hardware problem. Using Stop Mode 2 we expected about the same consumption.

What's missing so that i can achieve a lower consumption?

Here is the code snippet:

 

GPIO_InitTypeDef GPIO_InitStruct = { 0 };

// Configure the system clock

RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };

RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };

 

HAL_NVIC_DisableIRQ(ADC1_IRQn); // ADC INT

HAL_NVIC_DisableIRQ(EXTI1_IRQn); // GAUGE_NINT

HAL_NVIC_DisableIRQ(EXTI15_10_IRQn); // SENS_INT1

HAL_NVIC_DisableIRQ(EXTI3_IRQn); // IMU_DRDY

HAL_NVIC_DisableIRQ(TIM1_TRG_COM_TIM17_IRQn);

HAL_NVIC_DisableIRQ(TIM2_IRQn);

HAL_NVIC_DisableIRQ(TIM1_UP_TIM16_IRQn);

 

LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);

HAL_Delay(100);

 

lsm6dsl_stop(&lsm6dsl_driver); //POWER DOWN IMU SENSORS

HAL_I2C_DeInit(&hi2c1);

HAL_SPI_DeInit(&hspi2);

HAL_PCD_DeInit(&hpcd_USB_FS);

HAL_CRYP_DeInit(&hcryp1);

HAL_CRC_DeInit(&hcrc);

HAL_ADC_DeInit(&hadc1);

HAL_UART_DeInit(&hlpuart1);

 

HAL_SYSCFG_DisableVREFBUF();

 

/*Configure GPIO pin : PtPin */

GPIO_InitStruct.Pin = EXT_FLASH_CS_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(EXT_FLASH_CS_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : PtPin */

GPIO_InitStruct.Pin = EXT_FLASH_NWP_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(EXT_FLASH_NWP_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : PtPin */

GPIO_InitStruct.Pin = GAUGE_NINT_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GAUGE_NINT_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : PtPin */

GPIO_InitStruct.Pin = IMU_DRDY_ACCGYR_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(IMU_DRDY_ACCGYR_GPIO_Port, &GPIO_InitStruct);

 

__HAL_RCC_GPIOB_CLK_DISABLE();

__HAL_RCC_GPIOA_CLK_DISABLE();

__HAL_RCC_I2C1_CLK_DISABLE();

__HAL_RCC_USART1_CLK_DISABLE();

__HAL_RCC_SPI2_CLK_DISABLE();

__HAL_RCC_USB_CLK_DISABLE();

 

GPIO_InitStruct.Pin = IMU_GAUGE_SDA_Pin | IMU_GAUGE_SCL_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = EXT_FLASH_SCLK_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(EXT_FLASH_SCLK_GPIO_Port, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = EXT_FLASH_SDO_Pin | EXT_FLASH_SDI_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = USB_DP_Pin | USB_DM_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

GPIO_InitStruct.Pin = LPUART1_TX_Pin | LPUART1_RX_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

 

// Enable MSI oscillator

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;

RCC_OscInitStruct.MSIState = RCC_MSI_ON;

RCC_OscInitStruct.MSICalibrationValue = 0; // You can set a calibration value if needed

RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_4; // Adjust the range based on your requirements

HAL_RCC_OscConfig(&RCC_OscInitStruct);

 

// Select MSI as the system clock source and configure the HCLK, PCLK1, and PCLK2

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1

| RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV2;

RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

 

HAL_SuspendTick();

 

DBGMCU->CR = 0; // Disable debug and trace in low-power modes

 

LL_PWR_DisableBootC2();

 

HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);

 

HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

1 ACCEPTED SOLUTION

Accepted Solutions
MLuis.1
Associate III

Hello @Ronan GABOU and @STTwo-32,

I solved the problem by reordering the enable/disable of the gpio's.
Thank's for the help so far.

View solution in original post

5 REPLIES 5
STTwo-32
ST Employee

Hello @MLuis.1 

I suggest you take a look at the AN5071 and take a look at the STM32CubeWB low power examples to understand how it works.

Best Regards.

STTwo-32

 

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.

Hello @STTwo-32 

I already took into consideration that documentation and St examples. Please analyse the code i sent and check for anything i'm missing. 

Regards. 

Hello @MLuis.1 

Sorry for my late feedback.

Could you send your project so I can test this behavior.

Best Regards.

STTwo-32

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.

Ronan GABOU
ST Employee

Hello,

Just in case, to measure current consumption you must not be in debug mode.

You must flash the board then unplug and plug the power supply then measure the current.

Regards,

 

MLuis.1
Associate III

Hello @Ronan GABOU and @STTwo-32,

I solved the problem by reordering the enable/disable of the gpio's.
Thank's for the help so far.