cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L010RB, STOPmode with RTC wakeup.

videojames
Associate III

New to STM32 low power devices.

I cannot get power consumption of the nucelo to below 120ua when measuring at IDD. I have configured the ISR and RTC as per NUCLEO-L031K6\Examples\PWR\PWR_STOP_RTC

Any assistance would be highly appreciated.

I can get the module to also go into Standby but am experiencing the same high current.

void Stop_For(int seconds) {
	GPIO_InitTypeDef GPIO_InitStructure = { 0 };
 
	/* Enable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();
	__HAL_RCC_GPIOC_CLK_ENABLE();
	__HAL_RCC_GPIOH_CLK_ENABLE();
 
	/* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
	/* Note: Debug using ST-Link is not possible during the execution of this   */
	/*       example because communication between ST-link and the device       */
	/*       under test is done through UART. All GPIO pins are disabled (set   */
	/*       to analog input mode) including  UART I/O pins.           */
	GPIO_InitStructure.Pin = GPIO_PIN_All;
	GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStructure.Pull = GPIO_NOPULL;
 
	HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
	HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
	HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
	HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
 
	/* Disable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_DISABLE();
	__HAL_RCC_GPIOB_CLK_DISABLE();
	__HAL_RCC_GPIOC_CLK_DISABLE();
	__HAL_RCC_GPIOH_CLK_DISABLE();
 
	//RTC
	MX_RTC_Init();
 
	/* Start WakeUp Timer */
	HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, seconds, RTC_WAKEUPCLOCK_CK_SPRE_16BITS); //2 seconds
	/*Clear all related wakeup flags*/
 
	/* Enable Power Control clock */
	//__HAL_RCC_PWR_CLK_ENABLE();
 
	/* Enable Ultra low power mode */
	//HAL_PWREx_EnableUltraLowPower();
 
	/* Enable the fast wake up from Ultra low power mode */
	//HAL_PWREx_EnableFastWakeUp();
 
	/*Suspend Tick increment to prevent wakeup by Systick interrupt.
	 Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base)*/
	HAL_SuspendTick();
 
	/* Enter Sleep Mode , wake up is done once Key push button is pressed */
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);
 
	/* Resume Tick interrupt if disabled prior to s mode entry*/
	HAL_ResumeTick();
 
	SystemClock_Config();
	MX_GPIO_Init();
}

2 REPLIES 2
videojames
Associate III

So I have made some progress and can now get the STM32L010RB to go into DeepSleep.

The key appears to be:

/* 'To enter Stop mode, all EXTI Line pending bits (in Pending register EXTI_PR))
	 and RTC Alarm flag must be reset. Otherwise, the Stop mode entry procedure is ignored and program execution continues' */
	EXTI->PR = 0xFFFFFFFF;

However I am not entirely sure why this is the case. I would assume this would be handled by the HAL library?

Additionally, I can ge the device to 1.05ua on the first sleep cycle but after it wakes up the next sleep cycle and all following will be 2.6ua.

Some insight into the following would be appreciated:

  1. Why is the EXTI_>PR step necessary when using HAL Libraries?
  2. What is causing the increased current on second wake up?

My new function is:

void Stop_For(int seconds) {
	GPIO_InitTypeDef GPIO_InitStruct = { 0 };
 
	/* Enable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOH_CLK_ENABLE();
	__HAL_RCC_GPIOC_CLK_ENABLE();
 
	/* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
	/* Note: Debug using ST-Link is not possible during the execution of this   */
	/*       example because communication between ST-link and the device       */
	/*       under test is done through UART. All GPIO pins are disabled (set   */
	/*       to analog input mode) including  UART I/O pins.           			*/
	GPIO_InitStruct.Pin = GPIO_PIN_All;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
 
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
	//HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
	HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
	/* Button */
	GPIO_InitStruct.Pin = 13;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_PULLDOWN;
 
	/*Configure GPIO pin : B1_Pin */
	GPIO_InitStruct.Pin = B1_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
 
	/* BOOT */
//	GPIO_InitStructure.Pin = 13;
//	GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
//	GPIO_InitStructure.Pull = GPIO_PULLDOWN;
	/* Disable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_DISABLE();
	__HAL_RCC_GPIOH_CLK_DISABLE();
	__HAL_RCC_GPIOC_CLK_DISABLE();
 
	/* Clear all related wakeup flags */
	HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
 
	/* Start WakeUp Timer */
	HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, seconds, RTC_WAKEUPCLOCK_CK_SPRE_16BITS); //2 seconds
 
	/* Enable Ultra low power mode */
	HAL_PWREx_EnableUltraLowPower();
 
	/* Enable the fast wake up from Ultra low power mode */
	//HAL_PWREx_EnableFastWakeUp();
	/* */
	__HAL_RCC_PWR_CLK_ENABLE();
 
	/* Suspend Tick increment to prevent wakeup by Systick interrupt.
	 Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */
	//HAL_SuspendTick();
 
	/* 'To enter Stop mode, all EXTI Line pending bits (in Pending register EXTI_PR))
	 and RTC Alarm flag must be reset. Otherwise, the Stop mode entry procedure is ignored and program execution continues' */
	EXTI->PR = 0xFFFFFFFF;
 
	/* Enter Sleep Mode , wake up is done once Key push button is pressed */
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 
	/* Reconfigure our clocks */
	//SystemClock_Config();
 
	/* Resume Tick interrupt if disabled prior to s mode entry */
	//HAL_ResumeTick();
 
	/* Reconfigure GPIO */
	MX_GPIO_Init();
 
}

Mohamed Aymen HZAMI
ST Employee

Hello,

Did you first try the code example to see if it worked or not ?

Best Regards,

Mohamed Aymen.