help with the clock!!!

hi everyone!!

I’m porting device driver for vxwork to qnx 6.30 and i have problem with following:

/*
** Delaying execution
**
** os_get_time() Return system time since boot in ticks.
**
** os_delay_busy_us() Busy-delay for specified microseconds.
** Ties up the CPU it runs on.
**
** os_delay_thread() Delay for specified number of ticks. Must
** be running in a thread context and may be
** interrupted by signals.
**
** Returns TRUE if interrupted by a signal,
** otherwise FALSE.
*/

static void os_delay_busy_us(long x)
{

struct timespec t;
t.tv_sec=0;
t.tv_nsec=1000*x;
nanosleep(&t,NULL);

/* Counter Delay assuming that inner loop takes 1us */
/*int k,l;
for (k=0;k<x;k++)
for (l=0;l<2000;l++)
;
*/

}

#define os_ticks_per_second sysClkRateGet()

static unsigned long /* ticks */
os_get_time(void)
{
return (unsigned long) tickGet();
}

#define os_delay_thread(interruptable,x) taskDelay(x+1)
//-----------------------------------------------------------------------

sysClkRateGet();
tickGet();
taskDelay();

how to programming some similar or equivalent functions?

please!! help me!

thanks folks!!!

Have you tried compiling this on QNX yet? This should compile fine (i.e. no porting necessary).

yes that part does not need to be modified, yes works well, the problem is for the rest of the code.

But there is no other code (I don’t count 1 cover function and a macro as code)!

I suppose what you are asking is what are the equivalent of the following:

sysClkRateGet();
tickGet();
taskDelay();

The problem is I can’t give equivalents unless you specifiy the semantics of these calls. I can guess that tickGet() returns the current OS tick count; what I can’t guess is what exactly the tick count means on VxWorks (e.g. what is the period of a tick?).

I can direct you to the calls that I think might work for you. Look at:

ClockPeriod()
ClockTime()
SYSPAGE_ENTRY()

Hope that helps…

thanks!

/-------------------
sysClkRateGet() return the nurmer of ticks for second.

In QNX
A tick’s initial length is determined by the clock rate of your processor:
CPU clock speed: Default value:

= 40MHz 1 millisecond
< 40MHz 10 milliseconds

then there is 1000 ticks for second, that is true?

/------------------------------
tickGet() Return system time since boot in ticks, this function it’s use for compute the consumed time for some instructions.

I think that have use this function clock(), the logic is the same, is correct?

/-------------------------------------

taskDelay();

Can I use delay() ?

thanks!