Joseph Hadzima
2003-07-09 16:46:55 UTC
HI Yueshi:
There are several common methods used to do something
periodically.
1) // to do something and can tolorate +/- clk tick drift.
// taskDelay uses sysClk to monitor time.
myTask1()
{
for(;;)
{
taskDelay( NUM_SECONDS * sysClkRateGet() );
doSomething( doSomethingArg1 );
}
}
2)// to do something after N clk ticks and minimize drift
// also uses system clock to monitor time to call
WatchDog
doSomething()
{
myWDID = wdCreate();
mySemID = smeBCreate( SEM_Q_PRIORITY, SEM_EMPTY );
for(;;)
{
wdStart( myWDID, NUM_CLK_TICKS, semGive, mySemID );
semTake( mySemID, WAIT_FOREVER );
actuallyDoSomething()
}
}
3)
// to do something at a fast rate (i.e. > 500 Hz) .
// use Aux Clk so can set rate independent of sysClk rate
// CAUTION: doSomething() in this case is an ISR,
// and must comply with ISR design rules
// (no blocking calls, and no IO).
myTask3()
{
sysAuxClkRateSet( NUM_TICS_PER_SECOND );
sysAuxClkConnect( doSomething, doSomethingArg );
sysAuxClkEnable();
taskDelay( NUM_SECONDS * sysClkRateGet() );
sysAuxClkDisable();
}
those are the basics ... play with them to get a better
feel. BTW you can also use the wd timers to detect missed
dead-lines if you design yuor task to reload the timer
(call wdStart()) before the deadline occurs. If it does
occur then run code to handle the missed dead-line.
HTH and happy coding!
HADZ.
Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic.
(this Email sent using 100% recycled electrons)
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
There are several common methods used to do something
periodically.
1) // to do something and can tolorate +/- clk tick drift.
// taskDelay uses sysClk to monitor time.
myTask1()
{
for(;;)
{
taskDelay( NUM_SECONDS * sysClkRateGet() );
doSomething( doSomethingArg1 );
}
}
2)// to do something after N clk ticks and minimize drift
// also uses system clock to monitor time to call
WatchDog
doSomething()
{
myWDID = wdCreate();
mySemID = smeBCreate( SEM_Q_PRIORITY, SEM_EMPTY );
for(;;)
{
wdStart( myWDID, NUM_CLK_TICKS, semGive, mySemID );
semTake( mySemID, WAIT_FOREVER );
actuallyDoSomething()
}
}
3)
// to do something at a fast rate (i.e. > 500 Hz) .
// use Aux Clk so can set rate independent of sysClk rate
// CAUTION: doSomething() in this case is an ISR,
// and must comply with ISR design rules
// (no blocking calls, and no IO).
myTask3()
{
sysAuxClkRateSet( NUM_TICS_PER_SECOND );
sysAuxClkConnect( doSomething, doSomethingArg );
sysAuxClkEnable();
taskDelay( NUM_SECONDS * sysClkRateGet() );
sysAuxClkDisable();
}
those are the basics ... play with them to get a better
feel. BTW you can also use the wd timers to detect missed
dead-lines if you design yuor task to reload the timer
(call wdStart()) before the deadline occurs. If it does
occur then run code to handle the missed dead-line.
HTH and happy coding!
Hi,
I am using VxWorks 5.5 on PC Pentium III target. My
question is how
can I make use of the system clock to do something
regularly.
For example, the target computer will receive a command
from other
machine which indicates the start of such a function that
to read a
board every, say, 0.001 second.
So, what's the usual way to realize that on VxWorks, is
it relavent to
some routines in sysLib, for instance, sysAuxClkConnect()
etc.?
Also, if I wish to read the system clock, is that such a
function
availabe in VxWorks API library?
Thank you very much!
Sincerely
Yueshi
_______________________________________________
VxWorks Users Group mailing list
http://www-csg.lbl.gov/vxworks/
=====I am using VxWorks 5.5 on PC Pentium III target. My
question is how
can I make use of the system clock to do something
regularly.
For example, the target computer will receive a command
from other
machine which indicates the start of such a function that
to read a
board every, say, 0.001 second.
So, what's the usual way to realize that on VxWorks, is
it relavent to
some routines in sysLib, for instance, sysAuxClkConnect()
etc.?
Also, if I wish to read the system clock, is that such a
function
availabe in VxWorks API library?
Thank you very much!
Sincerely
Yueshi
_______________________________________________
VxWorks Users Group mailing list
http://www-csg.lbl.gov/vxworks/
HADZ.
Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic.
(this Email sent using 100% recycled electrons)
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com