Quality RTOS & Embedded Software

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


Loading

xTicksToWait - accuracy

Posted by yevpator75 on January 13, 2019

Hello

I just want to ensure I understand properly the meaning of the xTicksToWait parameter that exist in many of the API functions.

Assume I specify xTicksToWait to be 1, e.g. xSemaphoreTake (p_mutexHandle, 1). That is to say I want a timeout after 1 tick (1ms in my case). Can I say that the accuracy of this timing is 1 tick , or in other words, when I configure the timeout to be 1 tick, it can actually be any value in [0..1] ms range? So, if I want to prevent an immediate timeout, I need to cofigure the timeout at least 2 ticks instead of 1?

Thanks!


xTicksToWait - accuracy

Posted by richarddamon on January 13, 2019

Yes, the parameter is how many tick interrupts to wait, so if it is almost time for the next tick interrupt, the time period could be 1 tick short. The other thing to watch out for is with say a 10ms tick, the default pdMSTOTICKS will convert 15 ms to 1 tick, but if you really want an 'at least 15 ms' delay, you want to round any fraction up, and then add 1.

The one big exception would be when using the 'Delay Until' function, which bases the time on the previous timeout point, you don't need to plus 1, as your time referance point is exactly on a tick interrupt so no short period issue. This doesn't mean that a vTaskDelayUntil with a timeout of 1 will wait a full tick from the call, but a full tick from the last call waking up.

The other thing to remember is the delay can almost always be longer (unless you are the sole highest priority task) as a higher priority task running may prevent you from getting CPU time, even if you are woken up.


xTicksToWait - accuracy

Posted by yevpator75 on January 13, 2019

Thanks Richard, this answers my question.

Maybe I will just ask one more thing realted to this question. I am right now trying to understand where in the code the tick is managed , is there a task on the FreeRTOS level that handles the ticks ? Where can I find the tick management in the source ? Is that xTickCount that holds the current tick value?


xTicksToWait - accuracy

Posted by richard_damon on January 13, 2019

Most of the handling of the ticks are done in the Tick Interrupt, with a routine called something like TickIncrement that is called every tick, increments it and sees if any task needs to be woken, and if so initiates the scheduler.

There is also a task, the Sevice Task, that handles things like Timers, which are call backs that can be setup to be called at defined rates or elapsed time.


[ 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