FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2017 Threads] Strategy to implement a periodic task.Posted by simointe on March 6, 2017 Setup: FreeRTOS version is V9.0.0 (comes from here, download link at file menu), port TMS570.
My current implementation uses wait on notification and timeout value on this notification to be able to react on different events along have a periodic execution in case of no event.
BaseTypet xResult = xTaskNotifyWait( pdFALSE, // Don't clear bits on entry.
ULONGMAX, // Clear all bits on exit.
&ulNotifiedValue, // Stores the notified value.
nbTick );
The problem is that this design don't take into accompt the time to execute the thread itself. For instance, if it takes 200us to run my periodic thread of 1Khz, the resulting frequency will be around 800Hz instead of 1Khz.
A solution could be to use auto-reload timer to notify the task to run, which is in fact to use default timer task to notify my thread.
Is there another solution to make the thread more stand alone than using timer ?
Strategy to implement a periodic task.Posted by rtel on March 6, 2017 Am I right in interpreting this to mean you want to perform periodic
processing, and handle events in between each processing cycle?
There are two things that might work:
1) Use vTaskDelayUntil()
to get a fixed period, then use xTaskAbortDelay()
to unblock the task when an event needs processing.
2) Continue with a scheme similar to the one you are already using, and
use vTaskSetTimeOutState()
and xTaskCheckForTimeOut()
to adjust the time the task blocks to wait for the event so that the
task always unblocks when it is time to perform the periodic processing
again.
Strategy to implement a periodic task.Posted by simointe on March 7, 2017 That's right I want to perform periodic processing, and handle events in between each processing cycle. But that's not my problem here. My problem is that I "restart" my waiting (on timeout) AFTER I've done the execution of my task, so this execution time is added to the overall period.
Is there some API functions to soustract this execution time to the next timeout value ?
Strategy to implement a periodic task.Posted by edwards3 on March 8, 2017 thats what vTaskDelayUntil() does. When it unblocks is relative to the last time it unblocked so the time between calls doesnt matter.
Strategy to implement a periodic task.Posted by simointe on March 9, 2017 Ok, I see.
It's look like there is not the same built-in feature within Notification API. I guess I should to it by hand.
Strategy to implement a periodic task.Posted by richarddamon on March 9, 2017 Yes, the timeout parameters for the various API doesn't have the same 'until' feature as DelayUntil.
If you want a timeout for a given period from the point you last got an event, you would need to read the tick couter yourself and adjust. For me, most of the time the timeout period isn't that crutial, but is mostly to detect that something has gone wrong or away, so the variation isn't that important, if it is, you will need to correct for it.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|