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 2010 Threads] User timers for FreeRTOS?Posted by Juha on March 9, 2010 Hi,
In my application I need some timers. I will write those myself if I need to, but perhaps there is some code available already? I'm thinking of a system (in a relatively high priority task, perhaps?) that I can say something like "notify me every 500ms" or "do this after 12s". In more technical terms, start/stop a periodic/single_shot timer with somehow defining what to do at time out. Any pointers?
Thank you,
Juha
RE: User timers for FreeRTOS?Posted by Richard Damon on March 9, 2010 Look at the vTaskDelay and vTaskDelayUntil functions. As long as the period is a multiple of your tick rate, getting a task to wait up periodically isn't a problem.
RE: User timers for FreeRTOS?Posted by Juha on March 9, 2010 Yes, and the tick count is also available. However, I need to do things like starting a process that should be ready in two seconds. When doing that, I want the starting task to continue; I'll just set up a timer to send back a message after two seconds. If I get a message from the new process, I stop the timer and handle the new results. If I get a message from the timer, I'll do error handling.
I know FreeRTOS does not (yet :-) ) have this kind of services, but these can be readily created on top of it. As noted, I can write the timer code (timer task?) myself if I need to, but if there is something like this already, I rather not re-invent a wheel.
RE: User timers for FreeRTOS?Posted by Richard on March 9, 2010 I do have a (very) old timer module that allows timers to be generated dynamically, each of which with a callback function. However I have never included it in the main download, primarily because this sort of timer is very difficult to implement efficiently. Timer implementations normally do horrible things like walk linked lists inside critical sections, or even inside tick interrupts. That is something I have always tried to avoid in FreeRTOS because of the obvious adverse effect it has on system responsiveness.
I would suggest also taking a look at using a tick hook function. Most timer functionality (in the smaller systems that FreeRTOS targets at least) can be implemented using a tick hook.
Regards.
RE: User timers for FreeRTOS?Posted by Richard Damon on March 9, 2010 Sounds like one way to implement this is when task1 starts task2, it also starts up a watchdog task3 that does a wait for a signal from task2 with a timeout. When task2 is done, it sets the signal waking up the watchdog (which could process the data if you wanted), but if task3 wakes up on timeout (signal by a failure to get the signal), then it flags the error.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|