2021-03-09 07:04 PM
Hi!
My project consists of a bootloader and a main program that uses BLE functionality. If, after turning on the device, the main program was not started, then after switching the bootloader to STANDBY, I get a current consumption of 5 µA, taking into account the additional components on the board-OK. If the main program was started (respectively, CPU2->RUN), after the software reset, the bootloader puts the system in standbay, but the current consumption floats in the range of 30-70 µA. After that, the situation can only be changed by switching the power. I took code samples for switching to standby in STM32Cube_FW_WB_V1. 10. 1 PWR_EnterStandbyMode
//in start main() after HAL init:
if((LL_PWR_IsActiveFlag_C1SB() != 0) && (LL_PWR_IsActiveFlag_C2SB() != 0)){
LL_PWR_ClearFlag_C1STOP_C1STB();
LL_PWR_ClearFlag_C1STOP_C1STB();
}
// SLEEP device:
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
HAL_SuspendTick();
if((LL_PWR_IsActiveFlag_C1SB() == 0)|| (LL_PWR_IsActiveFlag_C2SB() == 0)){
// Set the lowest low-power mode for CPU2: shutdown mode
LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
}
LL_PWR_DisableWakeUpPin(LL_PWR_WAKEUP_PIN1);
// Clear all wake up Flag
LL_PWR_ClearFlag_WU();
// Enable pull up on wakeup pin
// Note: Setting not mandatory but recommended since there is no external pulling resistor on pin PA0 on STM32WB Nucleo board
LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_0); // SW1 button
.
.
.
// Enable pull-up and pull-down configuration for CPU1
LL_PWR_EnablePUPDCfg();
// Set wakeup pin polarity
LL_PWR_SetWakeUpPinPolarityLow(LL_PWR_WAKEUP_PIN1);
// Enable wakeup pin
LL_PWR_EnableWakeUpPin(LL_PWR_WAKEUP_PIN1);
// As default User push-button (SW1) state is high level, need to clear all wake up Flag again
LL_PWR_ClearFlag_WU();
// Set Standby mode when CPU enters deepsleep
LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
// Set SLEEPDEEP bit of Cortex System Control Register
LL_LPM_EnableDeepSleep();
// This option is used to ensure that store operations are completed
#if defined ( __CC_ARM)
__force_stores();
#endif
// Request Wait For Interrupt
__WFI();
I think the problem is in the CPU2 activity. Can you tell me where I am wrong in preparing for the transition to STANDBY mode?
Thanks!
2021-03-10 09:03 AM
Hello,
As long as you are measuring a power consumption below 100uA, The system is entering at least stop mode ( and likely standby in your setup).
Although this will not change much, you shall never modify the low power setup of CPU2 so please remove line 16. So far, you are writing the same value than CPU2 but if in some later release, the wireless firmware needs to change this, you will corrupt the CPU2 firmware state machine.
I would check the GPIO configuration as they are the root cause in 95% of the cases.
Make sure all IOs are set in input analog mode except PIN1 that you are using.
Regards.
2021-03-10 12:34 PM
You inspired me to check the external components again, and indeed, it turned out that the external i2c sensor was initialized in the main application and safely continued to make periodic measurements even after restarting the microcontroller)
Thanks!