# using vTaskDelayUntil in more then one task

**URL:** <https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621>\
**Category:** Kernel\
**Created:** [September 7, 2010, 9:40am UTC](https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621 "2010-09-07T09:40:15Z")\
**Posts on this page:** 4\
**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:** [September 7, 2010, 9:40am UTC](https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621/1 "2010-09-07T09:40:15Z")

</div>

**[dkilshtein10](https://sourceforge.net/u/dkilshtein10/)** wrote on [Tuesday, September 07, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/f95c0930/#2944):

I use FreeRTOS V6.0.5 on ARM1176JZF-S  
I created two small tasks to test freeRtos:

1st task - toggle LEDs using the vTaskDelayUntil function  
2nd task - just toggle LEDs

//the prototypes  
static portTASK\_FUNCTION\_PROTO( vLEDFlashTask2, pvParameters );  
static portTASK\_FUNCTION\_PROTO( vLEDFlashTask1, pvParameters );

void vStartLEDFlashTasks( unsigned portBASE\_TYPE uxPriority )  
{  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; xTaskCreate( vLEDFlashTask1, “LED1”, configMINIMAL\_STACK\_SIZE, ( void \* ) NULL, uxPriority, ( xTaskHandle \* ) NULL );  
&nbsp;&nbsp;&nbsp; xTaskCreate( vLEDFlashTask2, “LED2”, configMINIMAL\_STACK\_SIZE, ( void \* ) NULL, uxPriority, ( xTaskHandle \* )&nbsp; NULL );  
}

//task 1  
portTickType xLastWakeTime1;  
static portTASK\_FUNCTION( vLEDFlashTask1, pvParameters )  
{  
&nbsp;&nbsp;&nbsp; xLastWakeTime1 = xTaskGetTickCount ();

&nbsp;&nbsp;&nbsp; for( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil( &xLastWakeTime1, 1000 );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vParTestSetLED(1, 1);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil( &xLastWakeTime1, 3000 );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vParTestSetLED(1, 0);  
&nbsp;&nbsp;&nbsp; }  
}

//task 2  
static portTASK\_FUNCTION( vLEDFlashTask2, pvParameters )  
{  
&nbsp;&nbsp;&nbsp; for( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vParTestSetLED(0, 0);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; taskYIELD();  
&nbsp;&nbsp;&nbsp; }  
}

These tasks work fine (LED1 toggles with 1000, 3000 and LED 0 toggles all the time)

The problem occurs when i did the following:  
I changed the vLEDFlashTask2 to use vTaskDelayUntil (same as the vLEDFlashTask1 task)  
Now it looks like:

portTickType xLastWakeTime2;  
static portTASK\_FUNCTION( vLEDFlashTask2, pvParameters )  
{  
&nbsp;&nbsp;&nbsp; xLastWakeTime2 = xTaskGetTickCount ();  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; for( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil( &xLastWakeTime2, 500 );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vParTestSetLED(0, 1);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil( &xLastWakeTime2, 250 );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vParTestSetLED(0, 0);  
&nbsp;&nbsp;&nbsp; }  
}

The problem is, when I run the first vTaskDelayUntil (no matter on which task) I get “stuck” inside the idle task forever and nothing else happens.  
The tick timer works fine.

---

<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:** [September 7, 2010, 10:37am UTC](https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621/2 "2010-09-07T10:37:57Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, September 07, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/f95c0930/#f9e7):

\>&nbsp; I use FreeRTOS V6.0.5 on ARM1176JZF-S I created two small tasks to  
\> test freeRtos:

There is no official ARM11 port so I would be appreciate it if you could upload the code to the FreeRTOS interactive site:  
[http://interactive.freertos.org](http://interactive.freertos.org)

I think the modified code you describe that does not work has the exact same structure as the simple flashing led example that comes in the FreeRTOS download, so should work.&nbsp; Take a look at FreeRTOS/Demo/common/minimal/flash.c.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 7, 2010, 12:14pm UTC](https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621/3 "2010-09-07T12:14:35Z")

</div>

**[dkilshtein10](https://sourceforge.net/u/dkilshtein10/)** wrote on [Tuesday, September 07, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/f95c0930/#2027):

The code in the FreeRTOS/Demo/common/minimal/flash.c it acts as I described before.

---

<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:** [September 7, 2010, 12:19pm UTC](https://forums.freertos.org/t/using-vtaskdelayuntil-in-more-then-one-task/5621/4 "2010-09-07T12:19:12Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, September 07, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/f95c0930/#1ac4):

You mean it fails?&nbsp; That is about as simple a test as possible and runs without fault on countless architectures.&nbsp; Sorry to say, but I would suggest there is a problem in your port.

Regards.
