OK, I thought from some reason (Maybe the name “tickless” or the function name HAL_SuspendTick) that FreeRTOS tick is paused between the pre and the post SleppProcessing.
Now, as I see and as you explained so nicely, this is not the case and FreeRTOS set its next wakeup based on its internal calculation for the next schedule operation (task delay, OS timer etc.) and if there is no such operation waiting it use the maximum possible value (here I’m not sure I understand why it is a 24bit timer) that is based on the core clock (~4sec at 4MHz).
Now, what I’m doing at PreSleepProcessing is this:
__weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
{
HAL_SuspendTick();
// Wakeup after 10 sec
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x5000, RTC_WAKEUPCLOCK_RTCCLK_DIV16,0);
// Set STOP mode and wfi, set ulExpectedIdleTime to zero to signal
// vPortSuppressTicksAndSleep that the user implementation contains its own wfi
*ulExpectedIdleTime = 0;
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}
And I expect FreeRTOS to go to sleep and wake up after 10 sec, this does not happened.
Any idea what I’m doing wrong here?
Thanks