Newsgroups: comp.os.vxworks
From: pwhic...@home.com (Paul Whicker)
Date: 2000/07/08
Subject: Re: Periodic task
This will roughly work. The method with watchdogs also works most of the time.
If timing is critical then both of these approaches can suffer from drift and even missed events. If the system clock is fast in the following example then it may slip a tick now and then. The watchdog method also relies on getting processing time in task level to allow the watchdog to be reset. The clock tick may also not be suitable for achieving your timing accurately, there are methods to deal with this too (basically you keep a list of delay times that averages out or you work out the nearest number of ticks each time). Try this:- SEM_ID taskReleaseSem; void myTimedFunc(void) } void myTaskFunc(int tickParameter) // The clock tick passes a constant { for(;;) // Pick your favorite forever method { // Wait for the semaphore to be given semTake(taskReleaseSem); // Your periodic stuff } } void initTimedFunc(void) { // Create a semaphore to release the timed task taskReleaseSem = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY); // Set the aux xloxk to the desired rate // Spawn the task that does the work // Now connect the timer function to the aux clock } Now when the aux clock interrupt goes off the task is released, the timer is free running so you don't depend on the sysClk rate or getting some time at task level (not sure that's a fair criticism of the WD method but it is tied to the sysClkRate, this is not). HTH, taskSpawn options are:- VX_FP_TASK (0x0008) VX_PRIVATE_ENV (0x0080) VX_NO_STACK_FILL (0x0100) VX_UNBREAKABLE (0x0002) In article <39668b38.19865...@news.swbell.net>, snaph...@southwesternbell.net (Bruce) wrote:
>void MyTask(void) >{ > while(1) > { > DoSomething(); > taskDelay(sysClkRateGet()/20); // Delay 20th of second > } >} >Another poster mentioned using a watchdog timer and a sema4. That is also >Bruce You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||