panj wrote on Thursday, June 14, 2007:

Is FreeRTOS giving Timer functionality?

sotd wrote on Thursday, June 14, 2007:

Not directly but you can easily use the tick hook to implement timers.  The timer implementation of most RTOSs is hopelessly inefficient, decrementing timer counts on each interrupt.  All you need to do is count ticks within the tick hook then call your ‘timer’ function directly at the right time.  If you need multiple timer functions to fire at various rates then a common technique is to use a switch statement:

void vApplicationTickHook( void )
unsigned int Time:


____switch( Time )
________case 50: RunTimerFunction1();
________case 100: RunTimerFunction1();
_________________Time = 0;

This is a very simple example that can be expanded for more complex cases, but shows RunTimerFunction1() being called every 50 ticks and RunTimerFunction2() being called every 100 ticks.  This is much more efficient way of doing it in time and code size.