Showing results for 
Search instead for 
Did you mean: 

Need basic example for STM32U575 to use Standby mode within FreeRTOS

Associate III

I'm trying to get Standby mode to work, but no luck. Using the following code in STOP_MODE_2 everything works fine.

void StartMainTask(void *argument)
  /* USER CODE BEGIN mainTask */
  /* Infinite loop */
	  HAL_GPIO_TogglePin(LED_BLU_GPIO_Port, LED_BLU_Pin);
	  HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);

	  HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 5, RTC_WAKEUPCLOCK_CK_SPRE_16BITS, 0);
  /* USER CODE END mainTask */

If I uncomment HAL_PWR_EnterSTANDBYMode and comment HAL_PWREx_EnterSTOP2Mode doesn't work nothing.

Memory configuration is

  RAM	(xrw)	: ORIGIN = 0x20030000,	LENGTH = 64K 
  FLASH	(rx)	: ORIGIN = 0x08000000,	LENGTH = 2048K

RAM address is SRAM2 because is the only memory available in Standby, is It correct?

To wakeup I use RTC, that is configured correctly because in StopMode2 It is working as expected.

Is there an example about using Standby mode and FreeRTOS? Or is not possible to use FreeRTOS in Standby mode? What are the steps to correctly implement Standby mode?


Best regards


Lead II

Hello @GMG 

Yes, in standby mode, the only memory available is SRAM2.

For the FreeRTOS and standby mode, according to this post it's impossible to use the standby mode in a FreeRTOS context.

Best regards.



I think what's being lost here is that waking up from standby mode involves a system reset. It is certainly possible to enter standby mode with FreeRTOS, but when it wakes up, it will be similar to when the chip resets--It does not wake up at the same code location in which it went to sleep, like it does in STOP2 mode.

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

This is why the OP requests an example. It is possible, but restoring context is not trivial.

You'd have to stash some context in a place that's maintained (SRAM2), and recover that when you start bringing up the whole RTOS next time around. So it would require substantial thought about terminating all the other tasks/threads, and the mechanics about how you'd restart and get them back to the point where you're shutting the machine down.. Everything you do would need to be very stateful and restartable.  If the user can't understand the undertaking at that level, not sure an example that's simplistic will convey it sufficiently. Perhaps look at how STANDBY is done in normal implementations, and pivot in from there, if it's deemed an appropriate path forward.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

>>it's impossible..

You should review the Interstellar docking problem. There's a video..

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Associate III

Making some test and research I find what was the problem.
I Know that after Standby all is like reset with some exception but I was unable to wakeup again.
With the following code all It's working 



	  HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 3, RTC_WAKEUPCLOCK_CK_SPRE_16BITS, 0);


The only think I don't understand is 




why It's needed and is not documented ? I find that solution in another thread in the forum ( Link1, Link2 )

Inside IDE configuration there is the following section inside PWR

Screenshot 2023-09-13 111354.png

has something related? If I select WakeUp7 I only see interrupt pin PA6

Screenshot 2023-09-13 111643.png

Why inside IDE there isn't something related to RTC?

Can someone explain better?