This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Interrupts not waking FreeRTOS up in Tickless mode

Hi

I'm working with FreeRTOS with Tickless (RTC) and I was wondering what one should do in order to avoid the FreeRTOS Idle Task to be waken up every time an Interrupt Service Routine has completed the execution.

In Cortex-M4 the SLEEPONEXIT flag in SCR should help with this feature but I cannot let it work with Nordic. Any hints?

Thanks in Advance.

  • Hi Davide,

    The tickless idle sleep wakeup only processes to see if there any other pending interrupts to be processed. If there are and if they are lower in priority than the kernel itself, then idle task needs to do the book keeping. 

    Enabling SLEEPONEXIT would keep the state machine of the kernel stuck in the idle loop for ever and might cause asserts in the future. What is it you are trying to achieve exactly? why is the post processing of idle task wakeup seems to be very expensive in your usecase?

  • Thank you Susheel

    waking up the Idle task needs energy. If I could avoid it then I would be very happy.

    I have another project with a Cortex-M4 where I've done the folllowing:

    Let's say I call xTaskGenericNotifyFromISR

    The function delivers the flag pxHigherPriorityTaskWoken.

    I then check this flag in my ISR and, if set, I reset the SLEEPONEXIT flag. This ensures that the Idle task is woken up in order to perform the book keeping you were talking about.

    If the pxHigherPriorityTaskWoken flag is not set, I let the SLEEPONEXIT flag set and the processor will go directly in Sleep after the ISR, thus saving useless energy, because the Idle Task would do just nothing.

    This is very needed also because, if you Instrument the vPortSuppressTicksAndSleep, you will notice that it is executed always twice before it can go really in sleep mode. This is energy that I would like to save.

  • My example is taken from generic code, but basically I reset SLEEPONEXIT every time I'm sure a Task switch has to be performed.

  • Hi Davide,

     

    dfer said:

    Let's say I call xTaskGenericNotifyFromISR

    The function delivers the flag pxHigherPriorityTaskWoken.

    I then check this flag in my ISR and, if set, I reset the SLEEPONEXIT flag. This ensures that the Idle task is woken up in order to perform the book keeping you were talking about.

     This sounds like a reasonable thing to do, if there are only two tasks in your ssytem (the one giving notification and the other receiving it). But if there are other tasks, and if there is a dependency (inter task) between them, then your idea might not work.

    If only two tasks, then I think this will work.

  • In my other system I have about 30 tasks.

    I forgot to mention that the tick interrupt will always reset the SLEEPONEXIT flag (a Task switch is Always necessary in tickless mode at this Point).

    I cannot imagine why it shouldn't work, the other System runs since months with this method….

Related