During the IDLE period the system is in sleep mode, but the RTC1 is still running (will not wake the system up on every tick though). When the system wakes up from tickless idle sleep, then a correction is made to the internal RTOS tick based on how long the system slept in tickles idle and this calculation will be based on RTC1. Both BETA 2.9.2 and RTM 3.0.0 include FreeRTOS v10.0.1, and the Processor Expert component has been updated to reflect the current configuration options: The FreeRTOS configuration options configUSETICKLESSIDLEDECISIONHOOK and configUSETICKLESSIDLEDECISIONHOOKNAME have been deprecated from FreeRTOS for this version.
Matt - 2016-05-06
Trying to get the Tickless Idle working on my project. Using a Nucleo64 l476 board, used STMCubeMx to set the project up and had it install FreeRTOS.
Turned to Tickless Idle in the config.
First problem/question: How to get the code to start. Finally decided to suspend my two tasks, then put code in the interrupt to resume the tasks. That did not work and when I stepped through the freertos.c code I discovered that it did not work because it was determining that it could only sleep for 1 tick. Why 1 tick, because of the default idle task created by Cube:
So I decided to also suspend the idle task - don't know if that's a good idea, but it works.
I have a break point in PreSleepProcessing, and I'm finding that it is always called with ulExpectedIdleTime set to 209. I don't understand why, all the tasks are suspended, shouldn't it be infinate?
Also: I want to eventually put in code to change the CPU clock so I can enter stop mode. But I'm unsure how FreeRTOS is waking itself up and how changing the CPU clock would affect that.
Freertos Driver
So, how do I figure out why it is sleeping for 209 ticks? should I change the default idle task? is it ok to suspend the default idle task? could I use a vTaskSuspendAll? will changing the CPU clock mess things up?
Thanks so much - first time posting to this board!
-Matt
-Matt
Joseph - 2013-11-09
I am currently using atmel's atmsa4ls4a chip and using the AST instead of the SysTick for my rtos ticks. I was able to get this to run smoothly but am now having trouble with the vPortSuppressTicksAndSleep function. I use the freetos sample code as a baseline of my implementation.
In my implementation I put the system into retention mode and then let the ast wake up the system. When I try to disable the ast and enable the ast in the PortSupressTicksandSleep function the system hangs for some reason. I have stopped trying that and just set the counter value while the ast is running. This causes the system to hang after working for a little bit.
In my implementation I put the system into retention mode and then let the ast wake up the system. When I try to disable the ast and enable the ast in the PortSupressTicksandSleep function the system hangs for some reason. I have stopped trying that and just set the counter value while the ast is running. This causes the system to hang after working for a little bit.
Freertos Tickless Idle Service
Here is my implementation:
/ The tick interrupt handler. This is always the same other than the part that
clears the interrupt, which is specific to the clock being used to generate the
tick. /
void AST_ALARM_Handler(void)
{
/ Protect incrementing the tick with an interrupt safe critical section. /
( void ) portSET_INTERRUPT_MASK_FROM_ISR();
{
if( xTaskIncrementTick() != pdFALSE )
{
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
/ The tick interrupt handler. This is always the same other than the part that
clears the interrupt, which is specific to the clock being used to generate the
tick. /
void AST_ALARM_Handler(void)
{
/ Protect incrementing the tick with an interrupt safe critical section. /
( void ) portSET_INTERRUPT_MASK_FROM_ISR();
{
if( xTaskIncrementTick() != pdFALSE )
{
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
}
/-----------------------------------------------------------/
/-----------------------------------------------------------/
/ Override the default definition of vPortSetupTimerInterrupt() that is weakly
defined in the FreeRTOS Cortex-M3 port layer with a version that configures the
asynchronous timer (AST) to generate the tick interrupt. /
void vPortSetupTimerInterrupt( void )
{
struct ast_config ast_conf;
defined in the FreeRTOS Cortex-M3 port layer with a version that configures the
asynchronous timer (AST) to generate the tick interrupt. /
void vPortSetupTimerInterrupt( void )
{
struct ast_config ast_conf;
}
/-----------------------------------------------------------/
Vapplicationidlehook
/ Override the default definition of vPortSuppressTicksAndSleep() that is weakly
defined in the FreeRTOS Cortex-M3 port layet with a version that manages the
asynchronous timer (AST), as the tick is generated from the low power AST and
not the SysTick as would normally be the case on a Cortex-M. /
void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )
{
uint32_t ulAlarmValue, ulCompleteTickPeriods;
eSleepModeStatus eSleepAction;
portTickType xModifiableIdleTime;
enum sleepmgr_mode xSleepMode;
defined in the FreeRTOS Cortex-M3 port layet with a version that manages the
asynchronous timer (AST), as the tick is generated from the low power AST and
not the SysTick as would normally be the case on a Cortex-M. /
void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )
{
uint32_t ulAlarmValue, ulCompleteTickPeriods;
eSleepModeStatus eSleepAction;
portTickType xModifiableIdleTime;
enum sleepmgr_mode xSleepMode;
Freertos Download
}