Pumpkin, Inc.

Pumpkin User Forums

Cyclic Timer Questions

If you can't make Salvo do what you want it to do, post it here.

Cyclic Timer Questions

Postby Lo_Vaquero » Tue Sep 05, 2006 2:48 am

I have a couple questions regarding Cyclic Timers. I have not been able to determine the answers from either the manual or the source code:

1 - I'm assuming that with OSCT_ONE_SHOT mode set, the timer will only run once (after the initial delay) and not twice (once after initial delay and again after the period)? That is, the period field is ignored in OSCT_ONE_SHOT mode?

2 - If a cyclic timer is created with OSCT_ONE_SHOT set, can it be ran again (in OSCT_ONE_SHOT) without having to destroy and re-create it?

3 - What are the performance times for creating and destroying a cyclic timer?

I ask because I am trying to use cyclic timers in such a fashion that they should only run once, but with a configurable delay each time they run. That is, the timer runs once with a delay time of X, then is will run again at some point in the future with a time of Z. And so on. But I only want it to once once and then stop. I am not certain if this is achievable with cyclic timers.

Any help is greatly appreciated!

Lo_Vaquero
 
Posts: 9
Joined: Tue Sep 27, 2005 11:00 pm

Re: Cyclic Timer Questions

Postby aek » Tue Sep 05, 2006 3:19 am

quote:
1 - I'm assuming that with OSCT_ONE_SHOT mode set, the timer will only run once (after the initial delay) and not twice (once after initial delay and again after the period)? That is, the period field is ignored in OSCT_ONE_SHOT mode?
Correct.
quote:
2 - If a cyclic timer is created with OSCT_ONE_SHOT set, can it be ran again (in OSCT_ONE_SHOT) without having to destroy and re-create it?
No, you need to re-create it.
quote:
What are the performance times for creating and destroying a cyclic timer?
We don't quote performance times because they are highly dependent on compiler, target and Salvo configuration. You can obtain the times for your environment by measuring cycles in your IDE, especially since you have the source code.

Cyclic timers are meant to be very simple in nature. What you're trying to do is probably better done with a task, since the argument to OS_Delay() can be a variable. Do something like this:

code:
Task MyTimerTask(void)
{
while (1)
{
OS_WaitMsg(...);
delay = (cast)&msgP;
OS_Delay(delay);
do_something();
}
}

where you "fire" the task by signaling the message (which contains a delay). do_something() only happens after the message is signaled, and the delay between when the message is signaled and when do_something() happens is controlled by the message content (the delay). Timing on do_something() will be +/- 1 system tick, assuming that higher-priority tasks don't prevent it from running.

[This message has been edited by aek (edited September 05, 2006).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Cyclic Timer Questions

Postby Lo_Vaquero » Wed Sep 06, 2006 7:06 am

Thanks for the reply! I was thinking those would be the answers you'd give me, but I wasn't certain.

I completely forgot that I can simply measure cycles myself with Salvo Pro. I've spent too long in Windows land with that option unavailable...it's a slow adjustment to the freedom Salvo gives me =)

Lo_Vaquero
 
Posts: 9
Joined: Tue Sep 27, 2005 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron