Quality RTOS & Embedded Software

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


one-shot timer in FreeRTOS

Posted by umnrw on February 10, 2011

Is there any method to use one-shot timer in FreeRTOS?


RE: one-shot timer in FreeRTOS

Posted by Richard on February 10, 2011
The current V6.1.1 implementation of FreeRTOS does not have a specific method of doing this, although it is perfectly possible to use the tick hook, and other methods, etc. to obtain this functionality.

V6.2.0 of FreeRTOS (not released yet) has a new specific timer implementation that has this functionality. The implementation is in the head revision of the SVN repository now, although it is not complete yet because there is now overflow protection yet - I am adding that functionality today.

The timer implementation is not documented yet, although there is a demo/test app for it FreeRTOS/Demo/Common/Minimal/TimerDemo.c - again this is in the head revision of SVN. At the moment that file is a bit of a mess because there is a lot of test code in one large function. It will be modularised before release.

Writing a timer implementation is actually very easy - what is not easy is writing an efficient timer implementation. Often timers are written to execute in the interrupt context, which is not a good plan for the timer callback functions, and has an overhead on every single tick interrupt even when no timers need servicing. Also, implementations can require linked lists to be walked either in an interrupt, or with interrupts disabled. These are things that FreeRTOS never does. The implementation I have come up with hopefully gets around both these points. The timers are serviced by a timer daemon task, so executes in the task context. Also, the task blocks until a timer actually needs servicing, so there is no overhead when timers are all just waiting to expire.


RE: one-shot timer in FreeRTOS

Posted by Peter Kemmler on February 28, 2011
When will v6.2.0. be released? I'd like to appy freeRTOS Timer methods.

RE: one-shot timer in FreeRTOS

Posted by Richard on February 28, 2011
It will get released as soon as I have time to document the new features, and test some changes that were made to a couple of ports. In the mean time, you can obtain a copy of the timers code from the FreeRTOS SourceForge SVN repository. The timers code has completed testing now so should not change much if at all between now and release.

The file to add to a project in order to use software timers is FreeRTOS/Source/Timers.c

The demo application tasks (which are actually quite complex because they are more of a test task than a demo task) is in FreeRTOS/Demo/Common/Minimal/TimerDemo.c

The MSVC Win32 simulator demo has been updated to use the timer module, this is in FreeRTOS\Demo\WIN32-MSVC and uses the free MSVC Express edition to compile.

Note the MSVC project has the following additions to its FreeRTOSConfig.h:

#define configUSE_TIMERS1
#define configTIMER_TASK_PRIORITY2
#define configTIMER_QUEUE_LENGTH20

/* Nothing to do with timers, but to do with the new assertion points added in the core code. */
extern void vAssertCalled( void );
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()

The API for the timers module is in FreeRTOS\Source\include\timers.h *but* this is not yet commented.


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

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.


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


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