Quality RTOS & Embedded Software

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


Loading

Task scheduling using calendar

Posted by sfross on September 14, 2016

Hi,

I was wondering what other community members would do or are doing for a application where a task in a RTOS that needs to fire at a given time or regular interval (e.g every hour starting at midnight).

I intend using Free RTOS on an EFM32GG to implemenet this feature.

I could find only one method after a goggle search. The task requests the calendar time, calculates the amount of time until it next needs fire and and the sleeps for this amount of time. It seems a bit in accurate, but since I have not tried it I suppose I cannot comment.

Applogies if I have posted this in the wrong place.

Thanks,

Ross


Task scheduling using calendar

Posted by davedoors on September 15, 2016

The accuracy of vTaskDelayUntil() depends on the accuracy of the crystal running the EFM. External crystals are extremely accurate. Low power internal crystals can be very inaccurate. The normal thing is to have a separate real time clock. The EFM probably has one built in. You can then check then trigger tasks from interrupts generated off the real time clock (easy) or use the real time clock to calibrate and adjust the rtos tick (harder).


Task scheduling using calendar

Posted by sfross on September 16, 2016

Hi Dave,

Thanks for your reply, I realise now that I was a bit vague in my comment about accuracy. In the examples I have seen the RTOS uses the hardware counter and there is a software time used for the calendar. The reason for this seems to be that, if they share the counter, the RTOS does not like a wild change in hardware counter when the calendar is synchronised.

My concern, possibly invalid, the two counter system may give inaccuracy in timing.

In a super loop example the calculation of the minutes in the day is done at the begging of the loop and any state machine within the look and do something based on the modulus of the result of this calculation with a given interval.

In the RTOS world, I guess I was hoping for a mechanism where the RTOS is instructed to fire a task(s) or generate a semaphore to the task(s). The task(s) would wake up or run and go back to sleep until the next event.

Ross


Task scheduling using calendar

Posted by richard_damon on September 16, 2016

I woud impement such a system using the RTOS clock to handle short term incremental timing (something needs to happen in 10 seconds), and some service running off that clock maintains the Time-of-Day clock, as well as the occational adjustments to correct the Time-of-Day. This service is then fires off the various requests for things at particular time marks.


Task scheduling using calendar

Posted by jackfarmersedge on September 16, 2016

If your controller has an RTC with a calendar function then set it to interrupt on your preset time of day. The interrupt routine sets a flag to wake up the task. That's how I do it on an STM32.


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


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

Latest News

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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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