low power MCU in stopmode start using considerable amount of current after few minutes
Hi,
We have a STM32L031F6 which is used as an RTC. A weird phenomenon is occurring: when the controller goes to sleep, it only uses 2µA, but after 2 minutes and 40 seconds, it starts consuming 50 to 100µA, depending on the hardware board used. There is no external trigger at that moment, so we expect the controller to stay in sleep mode until the next external trigger. However, this consumption is also not enough for the run state of the controller, which consumes +500µA in run mode.
As a test, I set up an EXTI input to output mode and toggled the pin when the chip is out of sleep mode. When the power consumption is 2µA, this output is not active. When the consumption is 50-100µA, the output is not active. When the consumption is +500µA, the output toggles as expected.
What can cause this behavior? Could there be a problem with the chip itself? We only use the ADC, RTC, I2C, and TIM2 modules.

void ExitStopMode(){
SystemClock_Config();
HAL_ResumeTick();
}
void ExitStopModeWithExtPower(){
__HAL_ADC_ENABLE(&hadc);
MX_I2C1_Init(); // use this rude method because __HAL_I2C_ENABLE(&hi2c1) does not have the desired effect
tmr_ms_Start(&BatteryCheckTmr,3000); // first battery check , 3s after power up, then every hour
}
void EnterStopMode(){
// Goto STOP mode
allEventsStopped(); // do not enter STOP before all event timers are elapsed
//check power state again , if already ON exit the function
if(PowerApplied()) return;
__HAL_ADC_DISABLE(&hadc);
if (hi2c1.Instance != NULL) { HAL_I2C_DeInit(&hi2c1); } // use this rude method because __HAL_I2C_DISABLE(&hi2c1) does not have the desired effect
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);
}
// will be triggered on positive and negative edges of the tampering pins
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
ExitStopMode(); // needed the support HAL timers
}
bool PowerApplied(){
return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7);
}
int main(void)
{
/* USER CODE BEGIN 1 */
bool bSystemPoweredUp=1;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
MX_ADC_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
IntrusionInputs_Init();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if(PowerApplied()){
if(!bSystemPoweredUp){
ExitStopModeWithExtPower(); // the trigger was power-up event, spin up the I2C and ADC
bSystemPoweredUp = 1;
}
AliveTasks();
}
else{
bSystemPoweredUp = 0;
EnterStopMode(); // TODO extrea check !
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
