Board low power modes, alongside Tickless FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Board low power modes, alongside Tickless FreeRTOS

1,741 Views
gabrielsantamar
Contributor I

Greetings,

I'm trying to implement a very deep-state test project implementation, taking advantage of LLS state and FreeRTOS tickless operation;

for now, I can successfully enter RUN->VLPR->LLS state (which by itself is enough deep-state for the application i'm testing), but is required to do it within a function, not specially a task.

In parallel, I have also successfully put the current two FreeRTOS tasks I've created into the suspended state (by manually using vTaskSuspend( TaskHandle ), rather than vTaskSuspendAll() ) and then entered tickless operation.

The three main concerns I have for now are the following:

1) If I suspend all the tasks, including the current one running, task-internal-sequential-code is not continued (as the current task also enters suspended state and the core goes to tickless mode), so I can't call my function I previously mentioned to enter LLS.

2) I've read that the Idle task can redirect to a callback (also named "hook functions" I believe), but for now I haven't been able to perform that.

3) When I achieve tickless operation (which by the way, I configured to 1sec, i.e. 200 ticks with the default systick configuration), I don't see that any task is taken from the suspended state to running, as I understood from this link: Tickless Low power features in FreeRTOS ; am I supposed to manually resume (with vTaskResume(TaskHandle) ) any task I want to return to running? how would the core know when to listen to such sentence?

Any guiding/tip/example would be greatly appreciated, thanks in advance.

Best regads,

Gabriel

IDE:

MCU Xpresso IDE v10.2.0

 

SDK:

SDK_2.x_FRDM-KL43Z

0 Kudos
3 Replies

1,336 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Gabriel Santamaría ,

 There is a Tickless demo under SDK : FRDM-KL43Z \boards\frdmkl43z\rtos_examples\freertos_tickless

Please look at it combine with the tickless thread you mentioned:Tickless Low power features in FreeRTOS  .

About your three questions :

1) and 2)  when you suspend all the tasks , it meaning only active idle task, "When the tickless idle functionality is enabled the kernel will call the portSUPPRESS_TICKS_AND_SLEEP()", this will call cpu to sleep mode.

3)About " return to running"- "The value of portSUPPRESS_TICKS_AND_SLEEP()'s single parameter equals the total number of tick periods before a task is due to be moved into the Ready state." .

So  I think you will understand them after you read that Tickless thread carefully.

Hope it helps,


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,336 Views
gabrielsantamar
Contributor I

Greetings Alice,

I will examine the example you said, thanks, but do you know if it also sends the board to LLS? (I'm curious because that is particulary what I'm looking for: Tickless FreeRTOS and the ability to send the board to LLS);

regarding my three questions:

1) this can now be ignored because of the following answer in 2)

2) I mentioned that I couldn't make to work the hook function from the idle task, I've successfully perfomed that.

The new problem is that, even in such callback (and no current "running" task, all "Suspended" (as seen in the Task List tab) ), when I call my sleep function (which manually takes the board from RUN to VLPR to LLS), then the Tickless functions aren't called (I've tested placing a breakpoint where usually it ended before this callback, and the sentence name was somehow related to Tickless; if I continued step by step, eventually I reached where the portSUPPRESS_TICK_AND_SLEEP() was called).

3) I'm conscious of what you are explaining, thanks, I understood the same from the link I mentioned; the problem is, that after sending all my tasks (in this case, 2) to "suspended" state, the core enters TIckless operation, and I know it is supposed to put a task in "Running" after the amount of Ticks defined in the FreeRTOSConfig.h, which I set to 1 sec; but, running in debug, the program appears to stay for ever in Tickless operation (as it doesn't resume any task), and the only steps (when pressing F6) are related to such Tickless operation. 

For further information, one of my two tasks do the following:

void test_task(){

    uint16_t counter = 0;
    for(;;)

    {
        PRINTF("\nTEST %d ", counter);
        counter++;
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

So, in theory, my program should sleep for 1 sec, and then resume this task (as the other doesn't has a loop, and thus ends, because I delete it with vTaskDelete(NULL) )

Thanks,

Gabriel

0 Kudos

1,336 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Gabriel,

2) , The  function  void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ) is the

key to implement tickless ,you can call the low power mode function in it . Have a look at Tickless Freertos and LLS mode  .

This processing for this function called : Idle task "portTASK_FUNCTION( prvIdleTask, pvParameters )" call "portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );" (tasks.c).  ->

#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )

3) How about add your code based on the tickless demo , it can resume after the delay time :

/* Tickless Task */
static void Tickless_task(void *pvParameters)
{
    PRINTF("\r\nTick count :\r\n");
    for (;;)
    {
        PRINTF("%d\r\n", xTaskGetTickCount());
        vTaskDelay(TIME_DELAY_SLEEP);
    }
}


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos