2023-09-12 12:07 PM
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 */
for(;;)
{
HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
osDelay(500);
HAL_GPIO_TogglePin(LED_BLU_GPIO_Port, LED_BLU_Pin);
osDelay(500);
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
osDelay(500);
HAL_SuspendTick();
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 5, RTC_WAKEUPCLOCK_CK_SPRE_16BITS, 0);
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
//HAL_PWR_EnterSTANDBYMode();
SystemClock_Config();
HAL_ResumeTick();
}
/* 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
GMG
2023-09-12 12:35 PM - edited 2023-09-12 12:35 PM
2023-09-12 12:50 PM
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.
2023-09-12 01:58 PM - edited 2023-09-12 02:00 PM
This is why the OP requests an example. It is possible, but restoring context is not trivial.
2023-09-12 02:52 PM - edited 2023-09-12 02:52 PM
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.
2023-09-12 02:56 PM
>>it's impossible..
You should review the Interstellar docking problem. There's a video..
2023-09-13 02:19 AM - edited 2023-09-13 04:30 AM
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);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN7_HIGH_3);
HAL_PWR_EnterSTANDBYMode();
The only think I don't understand is
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN7_HIGH_3);
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
has something related? If I select WakeUp7 I only see interrupt pin PA6
Why inside IDE there isn't something related to RTC?
Can someone explain better?
2023-09-13 10:07 AM
Also read these topics, if you want it to actually work...
https://community.st.com/t5/stm32-mcus-motor-control/mc-sdk-not-work-with-mcu-stop-mode/m-p/94522