# Task never called

**URL:** <https://forums.freertos.org/t/task-never-called/8744>\
**Category:** Kernel\
**Created:** [February 4, 2020, 4:09pm UTC](https://forums.freertos.org/t/task-never-called/8744 "2020-02-04T16:09:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sallabra](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sallabra](https://forums.freertos.org/u/sallabra)\
**Post date:** [February 4, 2020, 4:09pm UTC](https://forums.freertos.org/t/task-never-called/8744/1 "2020-02-04T16:09:10Z")

</div>

Hi,  
I am trying to port the CORTEX\_R4\_RM48\_TMS570\_CCS5 demo to another TI processor (AWR1642, which is also an R4 ). Further more, I am using the most recent TI compiler (TLS 18.12.14).

I now have the Scheduler running (I call xTaskGetSchedulerState in the TickHook. The Scheduler state is switching between Suspended and Running). The Timer Interrupt is also running (xTickCount is incrementing). But the Sender and Receiver Tasks out of the basic “Blinky” Example are never called. I added a Handle for those tasks and the ucNotifyState is always 0.  
I tried increasing the heap and stack, nothing changed.  
pxCurrentTCB is always “TMR SVC”…  
Can anyone point me in the right direction?

---

<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:** [February 4, 2020, 5:25pm UTC](https://forums.freertos.org/t/task-never-called/8744/2 "2020-02-04T17:25:25Z")

</div>

It is common for the timer service task to have the highest priority in the system (configMAX\_PRIORITIES - 1), and so be the first task to start - but it should soon see it has nothing to do and block, yielding to the next task.

For now I would recommend starting with something even simpler. Set configUSE\_TIMERS to 0 in FreeRTOSConfig.h so the timer task doesn’t start, and configUSE\_TIME\_SLICING to 0 so the tick interrupt does not cause the tasks to switch. Then create two tasks as follows:

```auto
volatile uint32_t ulTask1Count = 0;
volatile uint32_t ulTask2Count = 0;

void vTask1( void *pv )
{
	for( ;; )
	{
		ulTask1Count++;
		taskYIELD();
	}
}

void vTask2( void *pv )
{
	for( ;; )
	{
		ulTask2Count++;
		taskYIELD();
	}
}

```

Create the tasks at priority 1 so the Idle task doesn’t run either.

Now put a break point at the top of each task and start the scheduler.

Each task should perform one increment of their variable, then yield to the other task. You can step through the Yield function to see what it does to get more information, then report back if need be.

Once you have the yields working you can remove the call to taskYIELD() from each task and set configUSE\_TIME\_SLICING to 1 - then both tasks should still run but switch from one to the other in the tick interrupt rather than by manually yielding to each other.

After that you should have manual yielding and yielding in the interrupt tested in isolation of each other.

---

<div class="post-metadata">

**Author:** ![sallabra](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sallabra](https://forums.freertos.org/u/sallabra)\
**Post date:** [February 5, 2020, 8:15am UTC](https://forums.freertos.org/t/task-never-called/8744/3 "2020-02-05T08:15:04Z")

</div>

Hi Richard,  
thanks a lot a for your help. I followed your steps exactly and all worked nicely. Both Task Counters are incrementing in all steps.  
Than I went back to configUSE\_TIMERS set to one with those 2 tasks and the behavior is again as descriped in my first post.  
But: Your comment that the timer task often has the highest priority I did some experiments with that.  
configTIMER\_TASK\_PRIORITY = 1, Task1 and Task2 = 2: Tasks are executed, but I think not the timer (CurrentTCB is always Task1 or Task2)  
With all priorities set to 2: Task1 and Task2 are executed once, than no more. CurrentTCB is IDLE  
configTIMER\_TASK\_PRIORITY = 4, , Task1 and Task2 = 2: Tasks are never executed, CurrentTCB is TMR SVC

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [February 5, 2020, 12:54pm UTC](https://forums.freertos.org/t/task-never-called/8744/4 "2020-02-05T12:54:42Z")

</div>

Could it be that the stack for the Timer Service task is to small and it is crashing the system? or maybe something is misconfigured and it is hitting an assert?

---

<div class="post-metadata">

**Author:** ![sallabra](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sallabra](https://forums.freertos.org/u/sallabra)\
**Post date:** [February 12, 2020, 11:02am UTC](https://forums.freertos.org/t/task-never-called/8744/5 "2020-02-12T11:02:08Z")

</div>

I have defined configASSERT and it is never hit, neither are vApplicationMallocFailedHook and vApplicationStackOverflowHook. I also watched the Stacks manually for each mode and they are large enough

I have one more observation (Tmr SVC with highest priority, Task1 and Task2 at same priority):  
I created a Software Timer (with the example given in [https://www.freertos.org/FreeRTOS-timers-xTimerCreate.html](https://www.freertos.org/FreeRTOS-timers-xTimerCreate.html) ) with a period of X. No tasks are called until X (i can see that xNextTaskUnblockTime is X) is reached for the first time. After X, all tasks are working as expected (xNextTaskUnblockTime is \< X, with the period of the tasks i configured). If the timer has deactivated the reload functionality, again no tasks are called.

How is it possible that a Software Timer is necessary for tasks not relying on a Software Timer?

---

<div class="post-metadata">

**Author:** ![sallabra](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sallabra](https://forums.freertos.org/u/sallabra)\
**Post date:** [March 23, 2020, 2:42pm UTC](https://forums.freertos.org/t/task-never-called/8744/6 "2020-03-23T14:42:08Z")

</div>

After getting more familiar with our processor, the problem became obvious and I must ask myself why this wasnt checked before:  
The portYIELD\_WITHIN\_API() macro and vPortYeildWithinAPI interrupt function needed to be implemented differently as the regarding registers and their behavior changed.
