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
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.
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.
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.
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.