Getting high current in low power mode

    while( 1 )
    {

    	SX1272Reset();

    	SX1272AntSwDeInit();

    	DelayMs(1);

    	SX1272Write(REG_DIOMAPPING1, 0xFF);
    	SX1272Write(REG_DIOMAPPING2, 0xFF);


    	GpioInit( &SX1272.DIO0, RADIO_DIO_0, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	GpioInit( &SX1272.DIO1, RADIO_DIO_1, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	GpioInit( &SX1272.DIO2, RADIO_DIO_2, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	GpioInit( &SX1272.DIO3, RADIO_DIO_3, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	GpioInit( &SX1272.DIO4, RADIO_DIO_4, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	GpioInit( &SX1272.DIO5, RADIO_DIO_5, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
    	DelayMs(1);

    	SX1272Write(REG_OPMODE, 0x01);
    	DelayMs(1);

    	SX1272Write(REG_OSC, 0x07);
    	DelayMs(1);

    	SX1272Write(REG_OPMODE, 0x00);
    	DelayMs(1);

    	SpiDeInit(&SX1272.Spi);
    	DelayMs(5);

    	UartDeInit(&Uart1);
    	DelayMs(1);



    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
    	DelayMs(700);




    	/*Configure GPIO pins : PC13 PC14 PC15 */
    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    	    	    	  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	    	    	  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    	    	    	  /*Configure GPIO pins : PH0 PH1 */
    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLUP;
    	    	    	  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	    	    	  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

    	    	    	  /*Configure GPIO pins : PA0 PA1 PA2 PA3
    	    	    	                           PA4 PA5 PA6 PA7
    	    	    	                           PA8 PA9 PA10 PA11
    	    	    	                           PA12 PA13 PA14 PA15 */
    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_0|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_INPUT;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    	    	    	  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    	    	    	  /*Configure GPIO pins : PB0 PB1 PB2 PB10
    	    	    	                           PB11 PB12 PB13 PB14
    	    	    	                           PB15 PB3 PB4 PB5
    	    	    	                           PB6 PB7 PB8 PB9 */
    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_0|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_INPUT;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    	    	    	  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	    	    	  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    	    	    	  DelayMs(1);

   // 	    	    	  GpioInit( GPIOA, RADIO_RESET, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_UP, 1 );

  /*  	    	    	  GpioInit( &SX1272.Spi.Nss, RADIO_NSS, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );

    	    	    	  GpioInit( &SX1272.Spi.Mosi, RADIO_MOSI, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );
    	    	    	  GpioInit( &SX1272.Spi.Miso, RADIO_MISO, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );
    	    	    	  GpioInit( &SX1272.Spi.Sclk, RADIO_SCLK, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );
    	    	    	  GpioInit( &SX1272.Spi.Nss, RADIO_NSS, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 );
*/
 //   	    	    	  GpioInit( GPIOA, RADIO_RESET, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 );

    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_4;							// NSS PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLUP;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_5;							// CLK PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_7;							// MOSI PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_6;							// MISO PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	    	    	  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_2;							// RADIO TX SWITCH PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_13;						// RADIO RX SWITCH PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);


    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_12;						// RADIO RESET SWITCH PIN
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);



    	    	    	  GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12
    	    	    			  	  	  	    |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;						// DIO PINS
    	    	    	  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    	    	    	  GPIO_InitStruct.Pull = GPIO_NOPULL;
    	    	    	  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);


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

    	    	    	  DelayMs(1);
    	    	    	  
		HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI );

}

This is my current code

@goshantry
Please read how do I format my forum post.

1 Like

In your latest code, you could maybe save some current by removing the pulldown/pullup on the GPIO that really don’t need them, i.e. everything but NSS.
Also, are you using the RTC with the LSE? You could scrap out a fraction of a uA if you’re willing to use the LSI.

Lastly: what is the value of VDD? If it’s 3.3V… well, replace your regulator with a 1.8V one. You might have to downclock the STM32 in RUN mode, but it’ll save some more current.

Found one pin which was floating and drawing around 1.5uA. Got my current consumption down to 8 uA. Thanks a lot everyone for your valuable inputs.

1 Like

I’m struggling with the power consumption too. Can you share your codes? Thank you in advance.