according to sx1272’s datasheet it should draw around 1uA of current in sleep mode. Is there any way that i can configure the io’s of sx1272. I might be wrong but i guess they remain in floating state that’s why it is drawing this much current
so the only thing the MCU does is setting the sx1272 to sleep and then itself ? if that’s the case I connect a multimeter between the power line and start fiddling with the different sleepmodes and instructions to the sx1272 and see what’s happening to the current draw.
or is there something still running ?
I am not sending any data packet. I tried connecting the CRO to check the output at various pins.
The HSE oscillator and the sx1272 oscillator are not working so is it fair to assume that both the IC’s are in sleep mode?
The RTC oscillator of 32khz is working fine but i guess that consumes around 100nA of current so i dont want to turn that off as i need to come out of sleep mode to transmit the data.
The current drawn by sx1272 in standby mode is 1.5mA. As i am getting the current in the range of 70uA so i guess both my IC’s are in sleep mode. Is the order in which i am turning them off wrong?
Any floating input pins? Used a meter to see if any.
probably … I was thinking the same… or maybe you forgot one registerinstruction or something.
I don’t know … have to look it up in the sheet myself
- maybe you can extract some info from the semtech driver
I made all the pins as input and pull up to avoid any kind of floating pins on stm32. i am unable to modify the sx1272 pins except for DIO and spi
SX1272Reset();
GpioInit( &AntTx, RADIO_ANT_SWITCH_TX, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );
GpioInit( &AntRx, RADIO_ANT_SWITCH_RX, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 );
// SX1272AntSwDeInit();
DelayMs(1);
SX1272Write(REG_DIOMAPPING1, 0xFF);
SX1272Write(REG_DIOMAPPING2, 0xFF);
// GpioInit( &SX1272.Spi.Nss, RADIO_NSS, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_UP, 1 );
GpioInit( &SX1272.DIO0, RADIO_DIO_0, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &SX1272.DIO1, RADIO_DIO_1, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &SX1272.DIO2, RADIO_DIO_2, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &SX1272.DIO3, RADIO_DIO_3, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &SX1272.DIO4, RADIO_DIO_4, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 );
GpioInit( &SX1272.DIO5, RADIO_DIO_5, PIN_INPUT, 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(7000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET);
DelayMs(2000);
/*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_PULLUP;
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_OUTPUT_PP;
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_PULLUP;
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_10
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GpioInit( &SX1272.Spi.Nss, RADIO_NSS, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 );
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
/*
__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_PWR_EnterSTANDBYMode();
i checked the current consumption at the rf side. when the led is glowing after disabling the RF part i get around 8uA of current at the sx1272. but after stm32 goes into sleep mode the rf part starts consuming 70uA of current.
The nss pin becomes floating as soon as i put the stm32 ic in stop mode. This was the reason behind the current consumption. When i put it in stop-mode instead with low power regulator on i am able to reduce the current to 9.5uA.
Can this be reduces further?
What about a very high pull-up or pull-down value, like 20k or something? If it’s floating, just about anything should pull it high, and it should not add much to the load when in use.
I cannot add another resistance as the size of the pcb is limited. I had to leave the unused pins as disconnected as well
There’s no way for the MCU to keep a pullup/pulldown in standby mode. All the pins will be set as floating inputs. Are you certain this is the mode you want to use however? You’ll lose everything in SRAM and the MCU will have to be reset to do anything.
EDIT: the datasheet says that standby mode will only use 0.3uA less than stop mode. Are you certain this is worth it?
I want to conserve the power as much as possible. When the MCU wakes up i would reset it, transmit the data and again put the device 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
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.
I’m struggling with the power consumption too. Can you share your codes? Thank you in advance.