Quality RTOS & Embedded Software

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


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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists