Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Periodic task
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul Whicker  
View profile  
 More options Jul 8 2000, 3:00 am
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)
{
    semGive(taskReleaseSem);

}

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
    sysAuxClkRateSet(20);

    // Spawn the task that does the work
    taskSpawn(
         "timed",           /* name of new task (stored at pStackBase) */
         100,                /* priority of new task */
         0,                    /* task option word */
         4096,               /* size (bytes) of stack needed plus name */
         myTaskFunc,   /* entry point of new task */
         0,                    /* 1st of 10 req'd task args to pass to func */
         0, 0, 0, 0, 0, 0, 0, 0, 0
         )

    // Now connect the timer function to the aux clock
    sysAuxClkConnect(myTimedFunc,0);
    // And switch it on
    sysAuxClkEnable();

}

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,
Paul

taskSpawn options are:-

     VX_FP_TASK (0x0008)
          execute with floating-point coprocessor support.

     VX_PRIVATE_ENV (0x0080)
          include private environment support (see envLib).

     VX_NO_STACK_FILL (0x0100)
          do not fill the stack for use by checkStack( ).

     VX_UNBREAKABLE (0x0002)
          do not allow breakpoint debugging.

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
>a good way if you NEED your task to run on the period because it will be
>executed at interrupt level.  This task will still run based on its
>priority.

>Bruce


    Reply to author    Forward  
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.

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google