Freertos Tickless Idle

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.

Freertos Tickless Idle

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. Jul 06, 2013  Low Power with FreeRTOS: Tickless Idle Mode. Posted on July 6, 2013 by Erich Styger. It took me a while to find the time to upgrade to FreeRTOS V7.4.2, but finally it is done:-). What caused me to move from V7.2 to V7.4 is a low power application on the FRDM-KL25Z board.

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;
}

}
/-----------------------------------------------------------/

Some day's ago, i worked on RT1051DVL6A with previous SDK (SDK2.3.0EVK-MIMXRT1050), configUSETICKLESSIDLE feature works. My project source code has the same phenomenon, so i verified on NXP SDK source code, unfortunately, it also has the same issue. Do we have any information on how to enable/support Tickless Idle mode in FreeRTOS on the PSoC 6 (ideally 63 BLE but any device)? There is some guidance.

/ 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;

}

/-----------------------------------------------------------/

/ 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;

}

Matt - 2016-05-06

Freertos With Tickless Idle Mode

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.

Freertos download

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:

Freertos

Vxworks Freertos

So I decided to also suspend the idle task - don't know if that's a good idea, but it works.

Freertos Tickless Idle Valve

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 Kernel

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?

Freertos Tickless Idle Work

Thanks so much - first time posting to this board!
-Matt