Quality RTOS & Embedded Software

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


Loading

Does vTaskdelay(1) delay up to one tick or circa one tick?

Posted by hooverphonique on January 28, 2019

I have a system consisting of 3 priorities on an Atmega1281 using FreeRTOS 9.0.0. Pri 0 is the idle task and RailTask. Pri 1 is SlaveTask. Pri 2 is the software timer task.

RailTask runs in a little loop which contains (a.o.) a vTaskDelay(1) statement. This old thread suggests that vTaskDelay(1) may resume the task on the next tick - depending on how far we are into the present tick when vTaskDelay(1) is called, this means that RailTask may get delayed arbitrarily less than one tick, is that correct? The reason I'm asking is that the system shows a rare problem which suggests that the delay is sometimes much shorter than expected (it's so rare that it's hard to do any diagnostics on it).


Does vTaskdelay(1) delay up to one tick or circa one tick?

Posted by rtel on January 28, 2019

There is only one answer to this:

Time resolution is set by the tick frequency. If, for example, you have a tick every 1ms, then vTaskDelay() will block for 0.00001ms if you call vTaskDelay( 1 ) immediately before the next tick interrupt, or 0.99999ms if you call vTaskDelay( 1 ) immediately after the next tick interrupt. To do anything else would take a lot of math (even floating point math) and (non portable) clock manipulation to get sub tick frequency interrupts within the kernel so the run time hit would not be tolerable to most applications.


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


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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

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