I am wondering about the compatibility of software timers and low-power tickless idle modes to sleep indefinitely. I read in the version history that around v8.2.3 there were enhancements/fixes made **"to the software timer code that allows tickless low power applications to sleep indefinitely when software timers are used". **
However, this does not appear to be working for me -- the software timers still wake the RTOS, so I'm unsure I've configured things correctly. I did not find any examples in "FreeRTOS/Demo" directory that illustrate tickless idle and software timers in use.
In my case:
- FreeRTOS v9.0.0
- (configOVERRIDEDEFAULTTICKCONFIGURATION == 1) and (configUSETICKLESS_IDLE == 2)
and I've defined the RTOS tick generated by RTC module at 128Hz.
- I have 3 tasks and 2 software timers (running at 32Hz and 4Hz).
When my application has nothing to do the tasks enter the blocked state with portMAXDELAY timeout and portSUPPRESSTICKSANDSLEEP(xExpectedIdleTime) is called, where xExpectedIdleTime = 2.
(I have set configEXPECTEDIDLETIMEBEFORESLEEP == 2 so the RTOS will want to stop the ticks and enter sleep very quickly.)
With a short idle time -- likely because of the software timers -- the RTOS wakes after a short time, as one would expect. I can't realize the functionality described in the FreeRTOS version history (bold section above); logically it doesn't seem possible, but apparently it's implemented?
Perhaps I misinterpret the comment or missunderstand how to configure the tickless idle to work in conjunction with software timers? I did try disabling/enabling the software timers in the portPRESLEEPPROCESSING/portPOSTSLEEPPROCESSING but that was a bad idea!
Perhaps the comment in the version history is incorrect? It seems to contradict
Software timers are not being used, so the scheduler is not due to execute a timer callback function at any time in the future. written here http://www.freertos.org/low-power-tickless-rtos.html
Could someone clarify?
I think the change history note you refer to was in relation to allowing
the tickless idle mode to be entered indefinitely EVEN WHEN software
timers were used (i.e. configUSE_TIMERS is set to 1 in
FreeRTOSConfig.h). Even when this is the case, software timers will
still execute when they time out, even if tickless idle has activated
and the MCU is in a low power state. It does not mean that software
timers top executing when the tickless mode is entered. In other words
the indefinite sleep will only be indefinite if there are no software
timers due to expire, otherwise sleep mode will be exited when the
software timer expires
Does that explanation help at all?
Thanks! This explanation helps a lot!
[I did not know how indefinite sleep (tickless idle) was impacted by configUSE_TIMERS == 1 in earlier versions. Now I understand that the software enhancements were made to allow tickless idle even with this option set, but it doesn't mean the software timers will stop executing when tickless mode is entered.]