FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2015 Threads]
Hi everybody,
dumb question. is this :
~~~~
TickTypet xTime = xTaskGetTickCount ();
for ( TickTypet x = xTime; x <= xTime + TOT; x = xTaskGetTickCount () )
{
//nothing
}
~~~~
a proper way to keep a task in running state for TOT number of tick?
Enrico
It is not clear why you would want to do this - but if it is your intention to just have a task run continuously for a fixed number of ticks, then the code you suggest has a couple of problems:
1) It assumes the task that is executing this code is the highest priority task. If it is not the highest priority task then it won't necessarily run continuously without being preempted.
2) I think the way you have formulated the tests will not take into account the tick count potentially overflowing. Better would be:
x = xTaskGetTickCount();
while( ( xTaskGetTickCount() - x ) < TOT )
{
}
3) The code might be optimised away if you turn on compiler optimisation. Best to make the variables volatile.
My goal is to create just a test application. Gold advices. thanks!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.