system
(system)
1
samanhamid wrote on Wednesday, November 06, 2019:
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);
}
}
}
htibosch
(Hein Tibosch)
2
heinbali01 wrote on Wednesday, November 06, 2019:
Could it be that this statement is mistaken:
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.
system
(system)
3
samanhamid wrote on Wednesday, November 06, 2019:
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);
}
}
}
htibosch
(Hein Tibosch)
4
heinbali01 wrote on Wednesday, November 06, 2019:
Try this:
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);
}
}
system
(system)
5
samanhamid wrote on Wednesday, November 06, 2019:
thank you very much
(while) worked but (for) not work
htibosch
(Hein Tibosch)
6
heinbali01 wrote on Thursday, November 07, 2019:
while
worked but for
(did) not work
A for-loop will also work, if you use the correct comparator.
These are two good examples:
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:
for ( i = 0; i > 100; i++ ) { LedBlink(); } /* no loops. */
for ( i = 99; i <= 0; i-- ) { LedBlink(); } /* no loops. */