cancel
Showing results for 
Search instead for 
Did you mean: 

On my STM32L476RG, my LPTimer does not work when in STOP1 mode.

Clark Sann
Senior

At startup I do initializations, then go to STOP1 mode. Initializations include setting a wakeup in the RTC and setting the wakeup clock to the MSI clock.

The RTC successfully wakes the MCU.

In the wakeup callback, I do some things then start a LPTIM. Then I go back to STOP1 mode. The LPTIM callback is never called.

void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
{
	/* *********  Called when time to acquire and store reservoir pressure ******** */
 
	// turn on reservoir level sensor power supply
	HAL_GPIO_WritePin(SENSOR_PWR_GPIO_Port, SENSOR_PWR_Pin, SET);
 
	// LPTIM1 is clocked by a 1 Hz pulse supplied by the RTC
	// Start 15 minute timer to allow level sensor to stabilize
	if (HAL_LPTIM_Counter_Start_IT(&hlptim1, SENSOR_STAB_SECS) != HAL_OK) {
	    Error_Handler();
 
	}
 
	HAL_GPIO_WritePin(GRN_LED_GPIO_Port, GRN_LED_Pin, SET);
 
//	HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
}

It is called if I remove the command to go to STOP1 mode as shown above. Why is this?

1 ACCEPTED SOLUTION

Accepted Solutions
Mohamed Aymen HZAMI
ST Employee

Hello @Clark Sann​ ,

Where do you place the other Stop1 command ?

Best Regards,

Mohamed Aymen.

View solution in original post

6 REPLIES 6
Mohamed Aymen HZAMI
ST Employee

Hello @Clark Sann​ ,

Can you please provide the project file ?

Best Regards,

Mohamed Aymen.

Clark Sann
Senior

@Mohamed Aymen HZAMI​ 

Thank you for helping me. I think I found the cause of the problem. If I remove the STOP1 command in the Callback, the device does go to sleep and the LPTim works properly. It appears the device automatically goes back to STOP1 mode if it was in STOP1 mode before the callback occurred. I think that putting the STOP1 command in there in addition to the automatic transition to STOP1 is what is causing the problem. Does this make sense?

Clark

Mohamed Aymen HZAMI
ST Employee

Hello @Clark Sann​ ,

Where do you place the other Stop1 command ?

Best Regards,

Mohamed Aymen.

> It appears the device automatically goes back to STOP1 mode if it was in STOP1 mode before the callback occurred.

Do you set SCB_SCR.SLEEPONEXIT bit?

JW

I have the STOP1 command in the main while loop.

I have solved this problem. As of yesterday my device is working extremely well in low power mode. I’ve gotten my RTC, ADC, LPUART, and LPTIMER working together perfectly. Like many things, there was a learning curve I had to climb before I got everything working right.

Now my NUCLEO-LPM01A shows my current in stop mode is only 37 uA and because I sleep most of the day my battery is projected to last 57 years!

Thanks to everyone on the forum who helped.

Hello @Clark Sann​,

I am glad that you solve your problem.

Best Regards,

Mohamed Aymen.