µTasker Forum
µTasker Forum => µTasker general => Topic started by: neil on September 08, 2008, 12:24:49 PM
-
Hi Mark,
I have a serial task where a string is sent through a serial port, and expects a reply within 2 seconds. Within the task I send the string and start a timer as follows:
uTaskerMonoTimer( TASK_OWNSERIAL, (DELAY_LIMIT)(2*SEC), E_TIMER_TIMEOUT );// start monitor timer
If I get a reply within the 2 seconds, how do I stop the timer from trigering the task?
Neil
-
Hi Neil
To stop the timer from firing, call:
uTaskerStopTimer(TASK_OWNSERIAL);
Note that the timer is a mono-stable one and can also be retriggered. Therefore if you want to start a new monitoring period you don't need to stop it, but instead calling
uTaskerMonoTimer( TASK_OWNSERIAL, (DELAY_LIMIT)(2*SEC), E_TIMER_TIMEOUT );
again will re-start it. You can also change the time delay or the timeout event if you like.
Regards
Mark
-
Hi mark,
I have a task that is sleeping, and want to wake it up in a certain condition. I initially set the task up as stopped, and when the criteria is met I do the following to wake it up after 1/th of a second:
uTaskerMonoTimer( TASK_COMMAND, (DELAY_LIMIT)(0.1*SEC), 0 );// wake task up.
Will this timer continue to fire, within this task, or do I have to use uTaskerStopTimer(TASK_COMMAND); within task to stop it refiring?
Neil
-
Hi Neil
The timer will only fire once (monostable) so you don't need to stop it.
If you do however want to stop a timer 'before' it has fired you can call uTaskerStopTimer(TASK_COMMAND);
Note also that you can start the task without any delay by using uTaskerStateChange(TASK_COMMAND, UTASKER_ACTIVATE); which will cause it to run just once.
Regards
Mark