# Problem with portSUPPRESS\_TICKS\_AND\_SLEEP and msp430fr4

**URL:** <https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288>\
**Category:** Kernel\
**Created:** [December 21, 2016, 8:51pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288 "2016-12-21T20:51:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 21, 2016, 8:51pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/1 "2016-12-21T20:51:05Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Wednesday, December 21, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#d8f0):

Hello,

I am trying to use the tickless low power feature of FreeRtos in my application.

I noticed that portSUPPRESS\_TICKS\_AND\_SLEEP never get called, the only way to make it work is disabling the only task that i have in my test application. This is very weird because the test task that i have only does this:

for(;😉  
{  
if(xQueueReceive(handler-\>events, &cur\_event, portMAX\_DELAY) == pdTRUE)  
{  
FSM\_Process((HSM\_PRIME\*) handler, &cur\_event);  
}  
}

I disabled all the interrupts that puts some data into this queue, so it would block indefinitely, leaving the system in IDLE state, i am using the IdleHook callback to make sure it is locked in this state, but still the portSUPPRESS\_TICKS\_AND\_SLEEP doesnt get called. This is VERY frustrating.

configUSE\_TICKLESS\_IDLE is 2  
configEXPECTED\_IDLE\_TIME\_BEFORE\_SLEEP is 200  
INCLUDE\_vTaskSuspend is 1

I really cant figure out what is happening, Could you guys help me?

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [December 22, 2016, 7:19am UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/2 "2016-12-22T07:19:28Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Thursday, December 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#43a4):

I can not think of a reason, but could you try replace `portMAX_DELAY` with a value of e.g. `1000`? Does that make a difference?

Could you through the code in `tasks.c` starting here:

```auto
    xExpectedIdleTime = prvGetExpectedIdleTime();

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 22, 2016, 11:45am UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/3 "2016-12-22T11:45:27Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Thursday, December 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#786a):

Tried different values. Still not working. xExpectedIdleTime is always 0 when my test tasking is running which is why portSUPPRESS\_TICKS\_AND\_SLEEP never get called. This two conditions are true in most times:

```auto
if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY )
{
    xReturn = 0;
}

```

```auto
else if( uxHigherPriorityReadyTasks != pdFALSE )
{
/* There are tasks in the Ready state that have a priority above the
			idle priority. This path can only be reached if
			configUSE_PREEMPTION is 0. */
			xReturn = 0;
}

```

I also modified my test task like this and still didnt work:

```auto
static void vTestTask(void * pvParameters)
{
	 TickType_t xLastWakeTime;
	 const TickType_t xFrequency = 450;

	 xLastWakeTime = xTaskGetTickCount();

	 for(;;)
	 {
		 vTaskDelayUntil( &xLastWakeTime, xFrequency );
	 }
 }

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 22, 2016, 12:00pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/4 "2016-12-22T12:00:11Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Thursday, December 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#331e):

Also noticed that this condition is always true when the test task is running

```auto
#if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
		{
			if( uxTopReadyPriority > tskIDLE_PRIORITY )
			{
				uxHigherPriorityReadyTasks = pdTRUE;
			}
		}

```

It is acting like even with vTaskDelayUntil or xQueueReceive blocking my task, it always counts as a Ready state. Cant figure out why this is happening.

Update: Now there is something even more weird, i **switched from FreeRtos v9 to FreeRtos v8.1** and it worked with the same application source code. I only got only one warning during the build related to cast in task.c.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 22, 2016, 8:45pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/5 "2016-12-22T20:45:08Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, December 22, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#e795):

This is on an MSP430F - did you provide your own implementation of the tickless idle feature? Which compiler are you using? If IAR then you should be able to use their StateViewer plug-in to see which task the system thinks is running.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 26, 2016, 5:55pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/6 "2016-12-26T17:55:46Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Monday, December 26, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#5295):

Yes, i made my own implementation, but the problem was that the portSUPPRESS\_TICKS\_AND\_SLEEP never get called. With some debugging i discovered that was because there was always at least one task in ready state which was not true since my only task was blocked due to vTaskDelayUntil.

Then I switched to FreeRtos 8.1 and the problem was gone.

I am using CCS 6.1 with Ti compiler.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 27, 2016, 3:20pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/7 "2016-12-27T15:20:49Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, December 27, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#4b49):

Are you using software timers? If so, then the change history for V8.2 could have explained it perhaps, but I’m not sure about 8.1: [http://www.freertos.org/History.txt](http://www.freertos.org/History.txt)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 28, 2016, 3:37pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/8 "2016-12-28T15:37:55Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Wednesday, December 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#fef0):

I am not using software timers. I just ported the freertos v9 to msp430fr4133 and made a simple tasks (that sleeps/blocks most of the time), but no matter what i do, all tasks always stays in ready status and then i couldnt make the tickless feature work.

I moved to freertos v8,1 and everything worked, but i get some warnings during the compilation.

I believe that is a problem with my enviroment and compiler, because there is a example code on freertos v9 with the msp430fr5 series that is very similar with my current msp430.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 28, 2016, 5:26pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/9 "2016-12-28T17:26:05Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, December 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#fef0/3048):

You can use the debugger to step through the prvGetExpectedIdleTime()  
function in tasks.c to see why it is returning whatever it is returning.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 29, 2016, 4:24pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/10 "2016-12-29T16:24:32Z")

</div>

**[eduardobern](https://sourceforge.net/u/eduardobern/)** wrote on [Thursday, December 29, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#12b5):

It always returns 0 because of this condition inside the prvGetExpectedIdleTime() function:

```auto
else if( uxHigherPriorityReadyTasks != pdFALSE )
{
/* There are tasks in the Ready state that have a priority above the
            idle priority. This path can only be reached if
            configUSE_PREEMPTION is 0. */
            xReturn = 0;
}

```

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 30, 2016, 4:16pm UTC](https://forums.freertos.org/t/problem-with-portsuppress-ticks-and-sleep-and-msp430fr4/6288/11 "2016-12-30T16:16:44Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, December 30, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/c2a2192f/#12b5/fe96):

That doesn’t help. uxHigherPriorityReadyTasks is set in that function.  
Why is it being set to pdTRUE?
