cancel
Showing results for 
Search instead for 
Did you mean: 

Unstable Current Consumption in Low Power Mode

VÜnal.1
Associate II

Greetings From Turkey,

We have a hardware using stm32l471. We wake up at certain times and send data to the server. Then we go back to sleep mode.

Here is the our callback to switch to low power consumption mode.

void low_power_callback (int time)
{
	sAlarm.Alarm = RTC_ALARM_A;
	sAlarm.AlarmDateWeekDay = 0;
	sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
	sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS;
	sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE;
	sAlarm.AlarmTime.Hours = 0x00;
 
	sAlarm.AlarmTime.Minutes = time;
	
	if  (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
	{
		Error_Handler();
	}	
 
	start_machine_loop = false;
	send_data_flag = false;
	GPIO_InitTypeDef GPIO_InitStruct;
  
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();
	__HAL_RCC_GPIOD_CLK_ENABLE();
	__HAL_RCC_GPIOE_CLK_ENABLE();
	__HAL_RCC_GPIOF_CLK_ENABLE();
	__HAL_RCC_GPIOG_CLK_ENABLE();
	__HAL_RCC_GPIOH_CLK_ENABLE();    
 
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Pin = GPIO_PIN_All;
 
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);  
 
	__HAL_RCC_GPIOA_CLK_DISABLE();
	__HAL_RCC_GPIOB_CLK_DISABLE();
	__HAL_RCC_GPIOC_CLK_DISABLE();
	__HAL_RCC_GPIOE_CLK_DISABLE();
	__HAL_RCC_GPIOF_CLK_DISABLE();
	__HAL_RCC_GPIOG_CLK_DISABLE();
	__HAL_RCC_GPIOH_CLK_DISABLE();
	
	HAL_Delay(10);
	HAL_PWREx_EnterSHUTDOWNMode();
	
}

While the current values ​​we see in sleep mode are sometimes as we want, sometimes they are high. We saw 0.700 micro amps, we saw 1ma value.

Are there any mistakes you see in the transition to sleep part?

If you have any other advice, I would like to listen.

Best Regards,

Volkan

2 REPLIES 2
TDK
Guru

You're using an uninitialized structure here. I'm surprised it works at all:

	RTC_HandleTypeDef RTCHandle;
	__HAL_RTC_WAKEUPTIMER_ENABLE(&RTCHandle);

If you feel a post has answered your question, please click "Accept as Solution".

i edited again.