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


Simulate tasks running for x tick

Posted by betlemme on November 11, 2015

Hi everybody, dumb question. is this :

~~~~ TickTypet xTime = xTaskGetTickCount (); for ( TickTypet x = xTime; x <= xTime + TOT; x = xTaskGetTickCount () ) { //nothing } ~~~~

a proper way to keep a task in running state for TOT number of tick?


Simulate tasks running for x tick

Posted by rtel on November 11, 2015

It is not clear why you would want to do this - but if it is your intention to just have a task run continuously for a fixed number of ticks, then the code you suggest has a couple of problems:

1) It assumes the task that is executing this code is the highest priority task. If it is not the highest priority task then it won't necessarily run continuously without being preempted.

2) I think the way you have formulated the tests will not take into account the tick count potentially overflowing. Better would be:

x = xTaskGetTickCount(); while( ( xTaskGetTickCount() - x ) < TOT ) { }

3) The code might be optimised away if you turn on compiler optimisation. Best to make the variables volatile.

Simulate tasks running for x tick

Posted by betlemme on November 11, 2015

My goal is to create just a test application. Gold advices. thanks!

[ 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