# Task not work

**URL:** <https://forums.freertos.org/t/task-not-work/8155>\
**Category:** Kernel\
**Created:** [November 6, 2019, 10:57am UTC](https://forums.freertos.org/t/task-not-work/8155 "2019-11-06T10:57:37Z")\
**Posts on this page:** 6\
**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:** [November 6, 2019, 10:57am UTC](https://forums.freertos.org/t/task-not-work/8155/1 "2019-11-06T10:57:37Z")

</div>

**[samanhamid](https://sourceforge.net/u/samanhamid/)** wrote on [Wednesday, November 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#17be):

I started programming freertos.  
i have Problem with thread

task work In this way :

void StartDefaultTask(void \*argument)  
{  
for(;😉  
{  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_14,1);  
osDelay(100);  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_14,0);  
osDelay(100);   
}  
}

when i use for  
task not work :

void StartDefaultTask(void \*argument)  
{  
for(;😉  
{  
for(int i=0;i\>10;i++){  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_14,1);  
osDelay(100);  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_14,0);  
osDelay(100);  
}  
}

}

---

<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:** [November 6, 2019, 2:56pm UTC](https://forums.freertos.org/t/task-not-work/8155/2 "2019-11-06T14:56:29Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Wednesday, November 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#f6b8):

Could it be that this statement is mistaken:

```auto
for(int i=0;i>10;i++){
}

```

It says: “while `i` is larger than 10” (`i>10`), which is not possible, because it was initialised to 0.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2019, 3:14pm UTC](https://forums.freertos.org/t/task-not-work/8155/3 "2019-11-06T15:14:55Z")

</div>

**[samanhamid](https://sourceforge.net/u/samanhamid/)** wrote on [Wednesday, November 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#2879):

thank you for answer

but not work this cod

void StartTask02(void \*argument){

```
int i=0;

```

for(;😉  
{  
for(i=1;i\>100;i++){  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_13,1);  
osDelay(100);  
HAL\_GPIO\_WritePin(GPIOG,GPIO\_PIN\_13,0);  
osDelay(100);  
}  
}

}

or this:

void StartDefaultTask(void \*argument)  
{

```
 int i=0;

```

for(;😉  
{

```
 while(i>100){
	 i++;
	HAL_GPIO_WritePin(GPIOG,GPIO_PIN_14,1);
osDelay(100);
	HAL_GPIO_WritePin(GPIOG,GPIO_PIN_14,0);
	osDelay(100);
 
 }

```

}

}

---

<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:** [November 6, 2019, 3:29pm UTC](https://forums.freertos.org/t/task-not-work/8155/4 "2019-11-06T15:29:23Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Wednesday, November 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#ba2c):

Try this:

```auto
for(;;)
{
    for(i=1;i<100;i++){
        HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13,1);
        osDelay(100);
        HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13,0);
        osDelay(100);
    }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 6, 2019, 3:51pm UTC](https://forums.freertos.org/t/task-not-work/8155/5 "2019-11-06T15:51:13Z")

</div>

**[samanhamid](https://sourceforge.net/u/samanhamid/)** wrote on [Wednesday, November 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#3173):

thank you very much  
(while) worked but (for) not work

---

<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:** [November 7, 2019, 3:54am UTC](https://forums.freertos.org/t/task-not-work/8155/6 "2019-11-07T03:54:38Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Thursday, November 07, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/0f838281f4/#7974):

> `while` worked but `for` (did) not work

A for-loop will also work, if you use the correct comparator.

These are two good examples:

```c
for ( i = 0; i < 100; i++ ) { LedBlink(); } /* 0, 1, 2 .. 99 */
for ( i = 99; i >= 0; i-- ) { LedBlink(); } /* 99, 98, 97 .. 0 */

```

In these examples, the LED will not blink:

```c
for ( i = 0; i > 100; i++ ) { LedBlink(); } /* no loops. */
for ( i = 99; i <= 0; i-- ) { LedBlink(); } /* no loops. */

```
