cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1CB with Zephyr sleep power consumption not going below 950uA

Stratosphere
Associate II

Using STM32G0 with zephyr on a board that has motion sensor, flow sensor, Quectel BG770 modem and Quectel FC41D modem. Modem power is controlled by the switch which is being turned off for sleep and various other peripherals are also being disabled but the power consumption won't fall below 950uA. This is my first project using SMT32 on zephyr so I am no expert and need help!

 

 

void enterLowPowerMode(void) { int err = 0; //TODO - implement low power mode // modem_disconnect(); modem_onOff(false); wifi_powerOnOff(false); GXHT3x_LowPower(); // err = pm_device_action_run(motionI2c, PM_DEVICE_ACTION_SUSPEND); // err = pm_device_action_run(tempI2c, PM_DEVICE_ACTION_SUSPEND); //I2C pins have external 47K pull ups err = gpio_pin_configure(wifi_gpioa_dev, 10, GPIO_DISCONNECTED); //i2c sda err = gpio_pin_configure(wifi_gpioa_dev, 9, GPIO_DISCONNECTED); //i2c scl // err = gpio_pin_configure(wifi_gpioa_dev, 10, GPIO_INPUT | GPIO_PULL_UP); //i2c sda // err = gpio_pin_configure(wifi_gpioa_dev, 9, GPIO_INPUT | GPIO_PULL_UP); //i2c scl err = gpio_pin_configure(wifi_gpioa_dev, 6, GPIO_DISCONNECTED); //spi miso err = gpio_pin_configure(wifi_gpioa_dev, 5, GPIO_DISCONNECTED); //spi sclk err = gpio_pin_configure(modem_gpiob_dev, 5, GPIO_DISCONNECTED); //spi mosi err = gpio_pin_configure(modem_gpiob_dev, 4, GPIO_DISCONNECTED); //spi ce //When these blank pins are configured as PULL_DOWN, the current consumption increases to 1.6mA //setting them to PULL_UP reduces the current to 0.950 uA err = gpio_pin_configure(modem_gpiob_dev, 1, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(modem_gpiob_dev, 3, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(modem_gpiob_dev, 8, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(modem_gpiob_dev, 9, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(modem_gpiob_dev, 10, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(modem_gpiob_dev, 15, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(wifi_gpioa_dev, 4, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(gpioc_dev, 6, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(gpioc_dev, 7, GPIO_INPUT | GPIO_PULL_UP); //blank err = gpio_pin_configure(gpioc_dev, 13, GPIO_INPUT | GPIO_PULL_UP); //blank // GPIO_InitTypeDef GPIO_InitStruct = {0}; // GPIO_InitStruct.Pin = B1_Pin; // GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; // GPIO_InitStruct.Pull = GPIO_NOPULL; adc_sleep(); // sensorI2C_sleep(); err = gpio_pin_configure(modem_gpiob_dev, 11, GPIO_DISCONNECTED); //red led // err = gpio_pin_configure(gpiod_dev, 0, GPIO_INPUT | GPIO_PULL_UP); //acc int 2 modem_uartSleep(); wifi_uartSleep(); user_uartSleep(); err = gpio_pin_configure(wifi_gpioa_dev, 3, GPIO_DISCONNECTED); //user uart tx err = gpio_pin_configure(wifi_gpioa_dev, 2, GPIO_DISCONNECTED); //user uart rx err = gpio_pin_configure(modem_gpiob_dev, 6, GPIO_DISCONNECTED); //modem tx err = gpio_pin_configure(modem_gpiob_dev, 7, GPIO_DISCONNECTED); //modem Rx err = gpio_pin_configure(modem_gpiob_dev, 13, GPIO_DISCONNECTED); //lte pwrkey err = gpio_pin_configure(modem_gpiob_dev, 14, GPIO_DISCONNECTED); //lte reset err = gpio_pin_configure(wifi_gpioa_dev, 12, GPIO_DISCONNECTED); //modem rts err = gpio_pin_configure(wifi_gpioa_dev, 11, GPIO_DISCONNECTED); //modem cts err = gpio_pin_configure(modem_gpiob_dev, 0, GPIO_DISCONNECTED); //wifi rx err = gpio_pin_configure(modem_gpiob_dev, 2, GPIO_DISCONNECTED); //wifi tx err = gpio_pin_configure(gpiod_dev, 3, GPIO_DISCONNECTED); //wifi wakeup //using PULL DOWN on these pins increases the power consumption err = gpio_pin_configure(gpiod_dev, wifiPinReset, GPIO_DISCONNECTED); //wifi rst err = gpio_pin_configure(gpiod_dev, wifiPinOnOff, GPIO_DISCONNECTED); //wifi on/off // err = pm_device_action_run(modem_gpiob_dev, PM_DEVICE_ACTION_SUSPEND); // err = pm_device_action_run(gpiod_dev, PM_DEVICE_ACTION_SUSPEND); // err = pm_device_action_run(gpioc_dev, PM_DEVICE_ACTION_SUSPEND); // HAL_RTCEx_BKUPWrite(Get_RtcHandle(), RTC_BKP_DR1, 0); // __HAL_RCC_PWR_CLK_ENABLE(); // HAL_SuspendTick(); // HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI); // HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); // __HAL_RCC_PLL_DISABLE(); // HAL_RCC_GPIOB_CLK_DISABLE(); // HAL_RCC_GPIOC_CLK_DISABLE(); // HAL_RCC_GPIOD_CLK_DISABLE(); } int main(void) { // Initialize the storage subsystem myStorageInit(); checkAndUpdateDeviceConfig(); bg770_ioInit(); terminalUartInit(); uart1LteInit(); uarWifieInit(); msa311_init(); temp_init(); adcInit(); printDeviceConfig(); // adcInit(); enterLowPowerMode(); // pm_state_set(PM_STATE_SUSPEND_TO_IDLE,1); /* indefinitely wait for input from the user */ while (1) { k_sleep(K_MINUTES(15)); } }
View more

 

Here is the code and the device tree and proj.conf files are attached.

Regards

 

2 REPLIES 2
Stratosphere
Associate II

Btw,

I can share the schematic privately if you let me know how.

Regards

Sarra.S
ST Employee

Hello @Stratosphere

I see many peripherals with status = "okay"; in your dts file (adc1, lptim1, i2c1, lse, gpioa, gpiod, gppioc, gpiob, usart1, usart2, usart3, tim3, tim1).

Make sure to enable only peripherals that are required for your application to save power. 

Also, GPIOs can cause increased power consumption if left floating, you're enabling GPIO A,B,C,D, determine which ones are not used, these should be set to input mode with pull-up or pull-down resistors. 

Try to review that and see if there is any decrease!

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.