STM32U545 Low-Power Mode with FreeRTOS
Hello, I am currently using the NUCLEO-U545RE-Q and trying to set low-power modes with FreeRTOS. I have already seen videos from official ST channel and read documentation but I cannot get to set this functioning when using FreeRTOS and RTC. My goal is to blink an LED every 5 seconds and in the reamaining time go to STOP mode for low power consumption. This are my functions:
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN defaultTask */
/* Infinite loop */
while(1)
{
osSemaphoreAcquire(BinarySemaphoreHandle, osWaitForever);
printf("Toggle Led\n");
BSP_LED_Toggle(LED_GREEN);
}
/* USER CODE END defaultTask */
}
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
{
printf("RTC Callback\n");
osSemaphoreRelease(BinarySemaphoreHandle);
}
void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
HAL_SuspendTick();
/* Start low power timer */
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 2000, RTC_WAKEUPCLOCK_RTCCLK_DIV16, 0) != HAL_OK)
{
Error_Handler();
}
/* Enter STOP2 */
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}
void PostSleepProcessing(uint32_t ulExpectedIdleTime)
{
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
SystemClock_Config();
/* Resume HAL timebase */
HAL_ResumeTick();
}
When I add the code inside PreSleep and PostSleep the LED simply does not blink. From printing debug, the application is always going to PreSleep and PostSleep non-stop and the RTC callback does not get fired. Can someone help me with this?
Best regards.
