This page augments the main low power tickless idle page with information that is specific to microcontrollers that use a ARM Cortex-M3 or ARM Cortex-M4F FreeRTOS port.
On this page:
If the SysTick timer frequency equals the core frequency then configSYSTICK_CLOCK_HZ must be defined to equal configCPU_CLOCK_HZ in FreeRTOSConfig.h. Alternatively, a definition for configSYSTICK_CLOCK_HZ can just be omitted, in which case it will default to equal configCPU_CLOCK_HZ.
If the SysTick timer frequency does not equal the core frequency then configSYSTICK_CLOCK_HZ must be defined in FreeRTOSConfig.h to equal the SysTick frequency (in Hz).
To define an alternative timer source:
Define a function to configure a timer to generate a periodic interrupt. The function must have the following name and prototype:
void vPortSetupTimerInterrupt( void );The frequency of the interrupt must equal the value of configTICK_RATE_HZ (which is defined in FreeRTOSConfig.h).
The FreeRTOS tick interrupt handler is called xPortSysTickHandler(). xPortSysTickHandler() must be installed as the handler for the timer that is configured by the application defined vPortSetupTimerInterrupt() function.
Some FreeRTOS demo applications map the name of the FreeRTOS tick interrupt handler to the default CMSIS SysTick handler name, which is SysTick_Handler(). This is done by including the following line in FreeRTOSConfig.h:
#define xPortSysTickHandler SysTick_HandlerThis must not be done if the tick interrupt is being generated by a timer other than SysTick.
Some FreeRTOS packages distributed by third parties have gone further by actually renaming xPortSysTickHandler() to SysTick_Handler() in the FreeRTOS port.c source file. If this is the case then a #define in FreeRTOSConfig.h can be used to reverse the change, as follows:
#define SysTick_Handler xPortSysTickHandler
In any case, it is important to ensure the FreeRTOS tick interrupt handler is not installed as the SysTick handler if the SysTick timer is not the interrupt source.
configPRE_SLEEP_PROCESSING() is executed immediately before the WFI instruction. It can be used to turn peripheral clocks off, and activate any microcontroller specific low power functionality.
The expected idle time in ticks is passed as the only parameter, and can be modified by the macro's implementation. If the implementation sets xExpectedIdleTime to 0 then WFI will not be called. This allows the macro's implementation to override the default sleep mode. It is dangerous to set xExpectedIdleTime to any value other than zero!
configPOST_SLEEP_PROCESSING() is executed as soon as the microcontroller leaves its low power state. It can be used to reverse the actions of configPRE_SLEEP_PROCESSING(), and in so doing, return the microcontroller back to its fully operational state.
The expected idle time in ticks is passed as the only parameter, and can be modified by the macro's implementation. Modifying the expected idle time after the microcontroller has left its low power state should only be attempted by expert users who fully understand the built in ARM Cortex-M low power implementation (by viewing the source code comments).