0
\$\begingroup\$

I'am using the STOP2 mode in stm32wb55 microcontroller. I followed the stm example code and got the desired behavior with a power consumption of 10 µA. However for my application I need to leave one GPIO pin enabled as an EXTI to wake up the MCU. When I did that I measured a current consumption of 100 µA which seems too high, is this consumption normal for 1 EXTI pin? If not is there any mistake in my code? Thank you.

`void stop2mode(){

HAL_UART_DeInit(&huart1);
HAL_UART_DeInit(&hlpuart1);
HAL_ADC_DeInit(&hadc1);
HAL_I2C_DeInit(&hi2c1);

GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = GPIO_PIN_All;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
GPIO_InitStructure.Pull = GPIO_NOPULL;

//  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);

//  __HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();

GPIO_InitStructure.Pin = GPIO_PIN_10;
GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);

/** ### Start the timeout function in interrupt mode ################# */
    

HAL_LPTIM_TimeOut_Start_IT(&hlptim1, 0xFFFF, period);
/* Enter STOP 2 mode */

HAL_SuspendTick();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_ResumeTick();

}`

\$\endgroup\$
3
  • \$\begingroup\$ 10uA is the advertised lowest current draw, 100uA seems pretty low when you have a pin enabled. What makes you think it's too high? \$\endgroup\$
    – Puffafish
    Aug 9, 2023 at 14:43
  • \$\begingroup\$ I have no idea how much does a GPIO port consume. I was using the interrupt from the low power timer to wake up the MCU and it was 17µA so 100µA seemed like a lot. I have to to reduce power to the minimum in sleep mode because the device will be mostly sleeping. \$\endgroup\$ Aug 9, 2023 at 14:49
  • \$\begingroup\$ without the schematics It is not possible to say. One pull or pull up can do this. \$\endgroup\$ Aug 9, 2023 at 17:35

2 Answers 2

0
\$\begingroup\$

I can't say without delving into the documentation just what will become enabled in an STM32 Cortex when you enable one GPIO, but at the very least, a clock on the GPIO peripheral gets turned on. 100 \$\mu A\$ doesn't seem unreasonable. You could try lowering the clock rate on that bus to see if you can nudge that number down. You should also check to see if you configured a pull-up or pull-down, and disable that if your design allows.

\$\endgroup\$
4
  • \$\begingroup\$ So i should check the clock tree in the datatsheet, and lower the speed of the APB or AHB bus that powers that GPIO ? \$\endgroup\$ Aug 9, 2023 at 15:08
  • \$\begingroup\$ @Faiz-983654 that's certainly one approach. I don't know how much quiescent current that will save, but even a little will start showing where the current is going. Also, I'd have to do some reading to figure out if "GPIO_InitStructure.Speed" does this or not. I also notice that you do, indeed, have a pulldown on that bit. Try disabling that. \$\endgroup\$ Aug 9, 2023 at 15:18
  • \$\begingroup\$ Also, why are you initializing 5 GPIO (B through E) to allow for one wake up bit? If those GPIO aren't all on the same bus, you might be turning on more than one bus clock. \$\endgroup\$ Aug 9, 2023 at 15:21
  • \$\begingroup\$ So i disabled the pull-down resistor but it did'nt change much. And the intilise function initilises the other GPIO ports as analog which consumes the least and than disables their clocks. I got that part from the ST example codes. \$\endgroup\$ Aug 10, 2023 at 7:21
1
\$\begingroup\$
GPIO_InitStructure.Pull = GPIO_PULLDOWN;

Internal resistance of the pin is between 30 to 50k. If supplied from 3.3V it will consume from 110uA to 66uA.

You have your power consumption :)

\$\endgroup\$
1
  • \$\begingroup\$ The pin is configured as Pull down so it is not connected to a 3.3v so theoretically it shouldn't consume anything. I tried configuring the pin as just a GPIO input with pulldown resistor and it doesn't consume any current. The excess consumption occurs when i configure it as an EXTI so i think it has something to do with the interupt handler circuit. \$\endgroup\$ Aug 10, 2023 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.