Skip to main content
Associate
Jul 25, 2025 8:40 AM UTC
Question

STM32L073RZ unable to enter sleep mode with STM32CubeIDE, but works in Keil.

Hello All,
I am very worried about this as time is short.
I am attempting to get my STM32L073RZ into low power mode using STM32CubeIDE version 19, and it wakes as soon as it sleeps. I am wondering if this is a problem with my code, or possibly an issue with the STM32CubeIDE?

I am attempting sleep mode like so:

void Enter_Stop_Mode(void)
{
	ConsolePrintf("Preparing to enter Stop mode\r\n");

 // Clear Wake-Up flag
 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);
 ConsolePrintf("RTC Wake-Up flag cleared\r\n");

 // Enter Stop mode (low-power mode)
 ConsolePrintf("Entering Stop mode\r\n");
 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 ConsolePrintf("Exited Stop mode\r\n");
}

 

And this fails. Am I the only one experiancing this, how have others got this working?
Are there any examples I could go off of?

For more context, here is my repo: https://github.com/CropWatchDevelopment/tempSensorx2
If anyone could help, I would be very greatful.
-Kevin

This topic has been closed for replies.

3 replies

Andrew Neil
Super User
Jul 25, 2025 8:48 AM UTC

@kevin192291 wrote:

 it wakes as soon as it sleeps.


How do you determine that?

Do you have 'Debug in low power modes' enabled in CubeIDE, but not Keil?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate
Jul 25, 2025 9:00 AM UTC

so, when waking from sleep, it initializes my usart1, then sends data over the serial line to my pc.
Then, I disable to usart, and all other periferals, and wait for my RTC to wake it up again. Sadly it wakes up immediately, I know because I get the instant response on the computer.

I have tried re-configuring the lpuart to a normal usart as it shouldn't wake my board, and I should be safe from any data coming back to wake the mcu up, but that also doesn't prevent the instant wake.

I am sure I am missing something, but the real problem is, where.... Any ideas where I am going wrong?