Quality RTOS & Embedded Software

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


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner