I’m trying to get the principle to work here and after that to make it work with my application.
My application needs to wake up only very limited times per day, based on an external event that will issue a wakeup.
When this wake up occurs some FreeRTOS activities will start (i.e. some tasks will be resumed or started and will communicate with messages and timer etc.) and at that time I plan to bypass the pre sleep by using flag or based on the xExpectedIdleTime so the system will not go to sleep.
Only when I’m ready to go to sleep I plan to suspend (or delete) the tasks and then the pre sleep will put the system to sleep.
At that sleep time I have no task or timer that needs to know the tick so I can freeze everything.
As I have an RTC I can always know the time passed when the system is wakeup from an external event or wakeup from a RTC wake up event as I want to be able to wake up a few times a day even if my external trigger was not raised (i.e. for keepalive handling).
The only issue I have know is that I cannot make this long sleep with the RTC wakeup to work.