Quality RTOS & Embedded Software

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




Loading

Correct way to keep ms counter in FreeRTOS? Tick rate for 1Khz tasks?

Posted by apullin2 on August 21, 2014

Is there a right or "best practices" FreeRTOS way to keep an accurate millisecond timer? In the project that I am slowly porting, a 1ms counter was kept by a hardware timer peripheral interrupting at 1Khz, but that timer also existed to launch into a 1Khz task, and a 500Hz task (divided via a toggling bit).

Moving to FreeRTOS, to keep an accurate 1ms counter for the whole system, should I just keep that one hardware timer dedicated to counting milliseconds? Or should I always derive my sense of time in the system from tick periods? I mean, I'm sure both methods could be made to work, but I am trying to learn & achieve proper RTOS implementation here.

Hand in hand with this, is there a guideline for how fast I should set my tick rate if I have several 1Khz tasks? The MCU clock speed is 40Mhz.


Correct way to keep ms counter in FreeRTOS? Tick rate for 1Khz tasks?

Posted by edwards3 on August 21, 2014

I dont think there is a 'right' way. However it works for you. I would probably set the tick interrupt to 1KHz then just use xTaskGetTickCount().


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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