Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem of periodic timer in Vxworks??

1,024 views
Skip to first unread message

trolls

unread,
Jun 28, 2002, 5:35:49 AM6/28/02
to
Hi.. all
 
I have a question of Vxwork program...
Currently I am using the MCP750 board..
 
   I want to make a timer which is operated per 1msec. For doing it, I think two kinds of method.
   The one is using the CPU clock timer, the other is using the H/W interrupt.
  
   In specification, Watchdog timer(WdStop(), WdStart()..) are used. But, In this case, system supports
   60Hz clock we can't get accurate 1msec.
  
   But I am the beginner of Vxworks.. How I can do it??

Michael Lawnick

unread,
Jun 28, 2002, 7:24:34 AM6/28/02
to
Hi trolls,

I fear you're a bit confused ...


> The one is using the CPU clock timer, the other is using the H/W
interrupt.

Where should be there a difference ?

You have different possibilities, minimum 2:

First: increase system clock rate with sysClkRateSet(1000), or best in
Workspace-configuration.
Now you can use e.g. taskDelay(1) to restart a task every ms.
Or you use sysClkConnect() to connect an ISR to system clock's interrupt.
Watchdogs should be able to work with 1ms too, but I'm not sure about
accuracy then.

Second: Use sysAuxClkRateSet(1000), sysAuxClkConnect(), sysAux... sequence
if your rate is supported.
Look into (Online-)Manual.

More: Use probably existing other timers. You might find information in
Motorola's Programmers User Guide.

HTH
Michael

"trolls" <trol...@hanmail.net> schrieb im Newsbeitrag
news:afhaim$psj$2...@news.kreonet.re.kr...

Harman bassan

unread,
Jun 28, 2002, 11:30:35 AM6/28/02
to
Hi trolls,

Check the config.h in CONFIG directory for your BSP. You should see
these lines in the Config.h file.

#define SYS_CLK_RATE_MIN 19 /* minimum system clock rate */
#define SYS_CLK_RATE_MAX (PIT_CLOCK/256) /* maximum system clock rate */
#define AUX_CLK_RATE_MIN 2 /* minimum auxiliary clock rate */
#define AUX_CLK_RATE_MAX 8192 /* maximum auxiliary clock rate */

They indicate the maximum clock rates you can achieve from your particular
board. Wind River doesn't recommend using SYS_CLK_RATE_MAX of more than 600
because it puts lots of overhead in task switching. SYS_AUX_CLK_RATE can be
increased to maximum rate without any trouble. There is one point about the
SYS_AUX_CLK_RATE, that it can only be incremented in the powers of two,
which means 2,4,8,16,.... So the closest one to your requirement would be
1024. Will that be ok with your application ? If not then you are better off
using some hardware interrupt through some timer. For that check
intConnect() in the help.

I hope it helps.

Harman.

"Michael Lawnick" <Law...@softec.de> wrote in message
news:afhh1h$m38$1...@snoopy.bndlg.de...

Friedrich Ensslin

unread,
Jul 3, 2002, 4:42:28 AM7/3/02
to
Hi,

"Michael Lawnick" <Law...@softec.de> schrieb im Newsbeitrag
news:afhh1h$m38$1...@snoopy.bndlg.de...


> You have different possibilities, minimum 2:
>
> First: increase system clock rate with sysClkRateSet(1000), or best in
> Workspace-configuration.
> Now you can use e.g. taskDelay(1) to restart a task every ms.

You better use taskDelay (0) here, because otherwise you'll stop your task
on every 2nd sys clock tick.

> Or you use sysClkConnect() to connect an ISR to system clock's interrupt.
> Watchdogs should be able to work with 1ms too, but I'm not sure about
> accuracy then.
>
> Second: Use sysAuxClkRateSet(1000), sysAuxClkConnect(), sysAux... sequence

Preferable to the sys clock as the aux doesn't carry the overhead of system
tick handling.

> if your rate is supported.
> Look into (Online-)Manual.
>
> More: Use probably existing other timers. You might find information in
> Motorola's Programmers User Guide.

This would IMO result in the same behaviour as the aux clock approach above
with the difference of having to program the timer yourself.

>
> HTH
> Michael

just my 2 EuroCents,

Fritz Ensslin

Michael Lawnick

unread,
Jul 3, 2002, 6:09:00 AM7/3/02
to
Hi Friedrich,

> > Now you can use e.g. taskDelay(1) to restart a task every ms.
>
> You better use taskDelay (0) here, because otherwise you'll stop your task
> on every 2nd sys clock tick.

That is definitely wrong! Keep your 2 EuroCents.

taskDelay (0) will start a pending task with same priority if existing, but
is a no-op if not !
taskDelay(x) waits for the x. occurence of system tick.
Assuming work doesn't last longer than a tick, the task will be restarted
every tick. If it needs longer, ticks will be missed. This is in contrast to
ISR, bound to any clock, that gives a binary semaphore. In this solution the
task will restart at once and so run continuously until work is done.

Michael

"Friedrich Ensslin" <friedric...@am3.com> schrieb im Newsbeitrag
news:AOyU8.3$9L3....@news.ecrc.de...

Emmanuel Herbreteau

unread,
Jul 3, 2002, 7:56:44 AM7/3/02
to
Michael Lawnick wrote:
> Hi Friedrich,

> > You better use taskDelay (0) here, because otherwise you'll stop your task
> > on every 2nd sys clock tick.
> That is definitely wrong! Keep your 2 EuroCents.
> taskDelay (0) will start a pending task with same priority if existing, but
> is a no-op if not !

Hi Mickael,

"This routine causes the calling task to relinquish the CPU for the duration
specified (in ticks). This is commonly referred to as manual rescheduling."
(from the Vxworks reference manual)

As far as I understand this statement, it seems that taskDelay(0)
will let the scheduler do its jobs (schedule the tasks) before
the next tick (no need to wait any longer as we know our task
has nothing to do).

???

Regards
Emmanuel

Johan Borkhuis

unread,
Jul 3, 2002, 8:15:27 AM7/3/02
to
Emmanuel Herbreteau <eherb...@sepro-robotique.com> wrote:

> As far as I understand this statement, it seems that taskDelay(0)
> will let the scheduler do its jobs (schedule the tasks) before
> the next tick (no need to wait any longer as we know our task
> has nothing to do).

The process of taskDelay(0) is the following:

The current task will be put at the end of the ready queue for the current
priority. Then the scheduler will look if there are any higher priority
tasks are ready, and if so these will be started. If not the first task at
the priority of the current task will be started. If there are no other
tasks ready at this priority the current task will continue.

Groeten,
Johan

--
o o o o o o o . . . _____________________________
o _____ || Johan Borkhuis |
.][__n_n_|DD[ ====_____ | bork...@agere.com |
>(________|__|_[_________]_|__________________________|
_/oo OOOOO oo` ooo ooo 'o!o!o o!o!o`
=== VxWorks FAQ: http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html ===

Friedrich Ensslin

unread,
Jul 3, 2002, 5:33:44 PM7/3/02
to
Yes Michael,

you're perfectly right (I mixed it up with the POSIX sleep(0) semantics).

Sorry for the inconvenience & have a nice time,

Fritz Ensslin

0 new messages