cancel
Showing results for 
Search instead for 
Did you mean: 

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

kevin192291
Associate II

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

3 REPLIES 3
Andrew Neil
Super User

@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.

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?

Quick followup!
I posted code & repo, here is my log ed output from the USART to my computer:

[2000-01-01 00:05:41] Going to sleep...
[2000-01-01 00:05:41] USART1 (DBG) Cnfigured
[2000-01-01 00:05:41] UART reinitialized
[2000-01-01 00:05:41] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:41] RTC Wake-Up Timer disabled
[2000-01-01 00:05:41] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:41] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:42] USART1 (DBG) Cnfigured
[2000-01-01 00:05:42] UART reinitialized
[2000-01-01 00:05:42] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:42] RTC Wake-Up Timer disabled
[2000-01-01 00:05:42] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:42] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:42] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:42] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:43] USART1 (DBG) Cnfigured
[2000-01-01 00:05:43] UART reinitialized
[2000-01-01 00:05:43] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:43] RTC Wake-Up Timer disabled
[2000-01-01 00:05:43] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:43] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:43] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:43] Going to sleep...
[2000-01-01 00:05:44] USART1 (DBG) Cnfigured
[2000-01-01 00:05:44] UART reinitialized
[2000-01-01 00:05:44] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:44] RTC Wake-Up Timer disabled
[2000-01-01 00:05:44] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:44] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:44] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:44] Going to sleep...
[2000-01-01 00:05:44] USART1 (DBG) Cnfigured
[2000-01-01 00:05:44] UART reinitialized
[2000-01-01 00:05:44] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:44] RTC Wake-Up Timer disabled
[2000-01-01 00:05:44] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:44] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:44] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:44] Going to sleep...
[2000-01-01 00:05:44] USART1 (DBG) Cnfigured
[2000-01-01 00:05:44] UART reinitialized
[2000-01-01 00:05:44] Starting RTC Wake-Up Timer configuration
[2000-01-01 00:05:44] RTC Wake-Up Timer disabled
[2000-01-01 00:05:44] RTC Wake-Up Timer Initialized for ~60 seconds
[2000-01-01 00:05:44] RTC Wake-Up interrupt enabled in NVIC
[2000-01-01 00:05:44] RTC Wake-Up Timer reinitialized
[2000-01-01 00:05:44] Going to sleep...