2023-03-05 04:02 AM
I'm trying to minimize the current consumption of an STM32G031K but I can't reach the ones calculated by the STM32CubeMX in any way. I tried with Low Power Sleep Mode, Stop Mode 0 and Stop mode 1. In Stop Mode 1, according to STM32CubeMX I should have 3.36uA, actually it consumes over 700uA. The MCU is connected in the minimum possible configuration: VDD=2.8V, GND, NRST connected to the 0.1uF capacitor, SWDIO and SWCLK. All other pins are not connected.
RCC->IOPSMENR = 0u;
RCC->AHBSMENR = 0u;
RCC->APBSMENR1 = 0u;
RCC->APBSMENR2 = 0u;
HSI divided by 128; LSI disabled; PLL disabled;
DBG->CR = 0;
PWR->CR1 |= PWR_CR1_FPD_STOP | PWR_CR1_FPD_LPSLP
SCB->SCR = SCB_SCR_SLEEPDEEP_Msk
PWR->CR1 |= PWR_CR1_LPR | PWR_CR1_LPMS_0 (just before WFI or WFE)
STM32CubeIDE PWR_LPSLEEP example, compiled as is, do not solve.
gpio set pin and gpio reset pin added just before and after WFI/WFE confirm that the MCU is executing the wait. The ST-Link is physically disconnected before power cycling the MCU and measuring the current.
The only way to go below 2uA is to go into Shutdown mode, but in this mode the MCU doesn't wake up if I generate an external interrupt (which I need).
What am I missing ?
Please help.
Solved! Go to Solution.
2023-03-21 03:34 PM
I solved. The problem was due to the configuration of the pins.
Configuring them all as analog inputs (except those used to generate the wake-up interrupt, which have been configured as input+EXTI), the consumption dropped below 3uA.
Attention should be paid to the pins that normally work as an output; in some cases, I had to configure them as inputs with pull-up/pull-down to maintain the desired output level. It is not possible to keep them configured as an output, otherwise the consumption increases by about 100uA for each activated output, in my case about 1.20mA (even though all the pins of the MCU are left unconnected, except obviously NRST, VDD and VSS).
Anyway, many thanks to Piranha for his time and trying.
2023-03-11 11:39 AM
Your code and approach seems adequate, but there still are some fine details, which could be critical. Try adjusting the code according to this article:
The Stop also have some specifics:
https://community.st.com/s/question/0D53W00001nYvGgSAK/mc-sdk-not-work-with-mcu-stop-mode
2023-03-21 03:34 PM
I solved. The problem was due to the configuration of the pins.
Configuring them all as analog inputs (except those used to generate the wake-up interrupt, which have been configured as input+EXTI), the consumption dropped below 3uA.
Attention should be paid to the pins that normally work as an output; in some cases, I had to configure them as inputs with pull-up/pull-down to maintain the desired output level. It is not possible to keep them configured as an output, otherwise the consumption increases by about 100uA for each activated output, in my case about 1.20mA (even though all the pins of the MCU are left unconnected, except obviously NRST, VDD and VSS).
Anyway, many thanks to Piranha for his time and trying.