Quality RTOS & Embedded Software

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


Loading

FreeRTOS SW Timers inaccurate

Posted by smurali on January 9, 2018

We have been using FreeRTOS SW timers all this while for periods ranging from 10ms to 1 minute. Recently we added a timer for 5 minutes. This paritcular timer seems very inaccurate. It usually takes around 5 minutes 45 seconds to trigger the interrupt. Is there something that i am missing?

configTIMERTASKPRIORITY is 2


FreeRTOS SW Timers inaccurate

Posted by rtel on January 9, 2018

Is there something that i am missing?

Don't know, as I don't know what you have.

Which port are you using? Does the chip have a stable and accurate clock? Or is it using a lower accuracy internal resonator? Have you checked the accuracy of the clock and the tick frequency using a scope? Are you setting the tick frequency to something that can be achieved exactly, or are you using a slow low power clock and attempting a tick frequency that can't actually be achieved exactly (considering rounding errors, etc.).


FreeRTOS SW Timers inaccurate

Posted by smurali on January 10, 2018

We are using a port with 64MHz CPU clock which is stable. The configTICKRATEHZ is set 1000


FreeRTOS SW Timers inaccurate

Posted by smurali on February 15, 2018

Any updates?


FreeRTOS SW Timers inaccurate

Posted by heinbali01 on February 19, 2018

We are using a port with 64MHz CPU clock which is stable. The configTICKRATEHZ is set 1000

Richard asked you a lot more. The information he's asking for is necessary to make a correct diagnosis.

These were his questions:

  • Which port are you using?

Richard is asking what platform and CPU you are using ( and please be exact about this ).

  • Does the chip have a stable and accurate clock?
  • Or is it using a lower accuracy internal resonator?

The phrase "64MHz CPU clock which is stable" is not really convincing. Maybe the CPU gets 64 MHz, but oscillators are usually slower, like e.g. 8 or 12 MHz. Can you tell what component is generating the clock? What are it properties? Or does it run on an internal resonator?

  • Have you checked the accuracy of the clock and the tick frequency using a scope?

Did you? I know that X-tals come in different qualities, just like resistors. Cheap resistors have a resistance of e.g. 22 K +/- 5%. The actual frequency of X-tals also varies from part to part.

  • Are you setting the tick frequency to something that can be achieved exactly?
  • Or are you using a slow low power clock and attempting a tick frequency that can't actually be achieved exactly (considering rounding errors, etc.).

On some platforms and for some clocks, a frequency of exactly 1000 Hz can not be produced, at the best an approximation. You will have to check the reference of your CPU and look-up the timer that produces the FreeRTOS clock-tick. It has an input frequency ( which can be changed in some cases ), and it has a divisor. You will find a formula like:

~~~ F-output = F-input / divisor ~~~

If the deviation can be explained and if is quite constant ( 5:45 in stead of 5:00 ), you may want to "calibrate" the clock and use a different frequency in your calculations ( E.g. 869 Hz ).


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


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

Latest News

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.


Careers

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

Renesas

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