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] [June 2007 Threads] timerPosted by Chaks on June 14, 2007 Is FreeRTOS giving Timer functionality?
RE: timerPosted by sotd on 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:
____Time++;
____switch( Time ) ____{ ________case 50: RunTimerFunction1(); ________________break; ________case 100: RunTimerFunction1(); _________________RunTimerFunction2(); _________________Time = 0; _________________break; ____} }
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|