Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

timer

Posted by Chaks on June 14, 2007
Is FreeRTOS giving Timer functionality?

RE: timer

Posted 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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS