Hello,
In the project I am developing, there are processes that require time within certain tasks. For example, did the X value fall below 60 within 10 seconds? Here, instead of using the timers that FreeRTOS has, I placed a for loop and counter in the task called every 1 ms. For example, the counter increments by 1 each time the task returns. When the counter value is 1000, it is thought that 1 second time has passed, and when it is 10000, 10 seconds is considered to be completed.
Do you think this is the right approach? Are there any drawbacks? What is the advantage of using FreeRTOS software timer instead? You can see the code block I wrote for the counter incrementing process I mentioned below.
if( ucFiveSecTimerStatus == TIMER_START)
{
if( ucErrorTimerMsFive < 1000U)
{
ucErrorTimerMsFive ++;
}
else if( ucErrorTimerMsFive == 1000U)
{
ucErrorTimerMsFive = 0;
if( ucErrorTimerSecFive < 5U)
{
ucErrorTimerSecFive ++;
}
else if( ucErrorTimerSecFive == 5U)
{
ucErrorTimerMsFive = 0;
ucErrorTimerSecFive = 0;
ucFiveSecTimerStatus = TIMER_TIME_IS_UP;
}
else
{
ucStatus = statusERROR;
}
}
else
{
ucStatus = statusERROR;
}
}
else if( ucFiveSecTimerStatus == TIMER_STOP || ucFiveSecTimerStatus == TIMER_TIME_IS_UP)
{
ucErrorTimerMsFive = 0;
ucErrorTimerSecFive = 0;
}
else
{
ucStatus = statusERROR;
}