“Mario Charest” <mcharest@nowayzinformatic.com> wrote in message
news:9o29fn$1k0$1@inn.qnx.com…
“Augie Henriques” <> augiehenriques@hotmail.com> > wrote in message
news:9ntpo3$cl9$> 1@inn.qnx.com> …
“Mario Charest” <> mcharest@nowayzinformatic.com> > wrote in message
news:9ntnhr$bcu$> 1@inn.qnx.com> …
“Augie Henriques” <> augiehenriques@hotmail.com> > wrote in message
news:9ntjcr$943$> 1@inn.qnx.com> …
“Mario Charest” <> mcharest@nowayzinformatic.com> > wrote in message
news:9ntiif$8pg$> 1@inn.qnx.com> …
“Augie Henriques” <> augiehenriques@hotmail.com> > wrote in message
news:9ntdp2$5v5$> 1@inn.qnx.com> …
At the top of the file I declare…
volatile GnTime systemTime;
struct _osinfo osdata;
volatile struct _timesel far *tptr;
Inside the IRQ handler I do…
// get qnx system time
do {
systemTime.sec = tptr->seconds;
systemTime.nsec = tpr->nsec;
} while
((systemTime.sec!=tptr->seconds)||(systemTime.nsec!=tptr->nsec));
Are systemTime.sec and nsec floating point?
This should work. However it would be faster to read the
Faster to read what? I hear the word “faster” and I get a smile in
my
face.
Woops sorry about that, see below.
In main, I initialize these
qnx_osinfo(0, &osdata);
tptr = MK_FP(osdata.timesel, 0);
// then start the interrupt handler
Is this a problem? How do you get the current time in sec and
nsec
inside
the IRQ handler? I can’t read it in the proxy, by then it will
be
off
by
a
small amount of time.
Yes but that irrelavent ( to some degree) since this time is NOT
precise to the nanosec. To get maximum precisoin use the rdtc (?)
assembly instruction
Okay, How do you do this?
The problem with rdtc is that it only works on Pentium (486 don’t have
that instructions)
Download:
ftp://ftp.qnx.com/usr/free/qnx4/os/utils/examples/Micro_time.tgz
There is a file rtdc.c (from memory) that shows how to do it.
The number read is in CPU clock unit, you must apply a scaler to
convert
it into seconds but that can be done outside of the interrupt.
Reading
this is faster because the CPU doesn’t to go read memory. However
if you need a apply a scaler it will be slower overall. But you’ll
get a LOT more precision!
Sorry, I’m confused.
I’m to blame >
I would like to read PC system time not something
specific to the CPU? Does the CPU also keep hardware clock?
When to program starts you read BOTH system time and CPU counter.
You keep both these numbers that means later by rereading the CPU
counter you are able to figure out a new time value.
((current CPU clock) - (original CPU clock) * SCALER + System TIME) = new
time
This may be overly complicated for you case.
Maybe we should get back to the original problem,
your program shouldn’t crash. Do you get a kernel crash or
only a program crash?
It turns out that I can read the system clock from the interrupt handler as
mentioned above. I was also reading another time from an IRIG B card. This
is were I have a problem now. To get the IRIG B time I have to access dual
port ram.
Is this allowed from the interrupt handler?
TIA
Augie
TIA
Augie
Include this:
There is and example
Initially, I was told to use the above method.
TIA
Augie
TIA
Augie
“Operating System for Tech Supp” <> os@qnx.com> > wrote in message
news:9ntb6r$1bh$> 1@nntp.qnx.com> …
Augie Henriques <> augiehenriques@hotmail.com> > wrote:
Is it possible to do this inside the IRQ handler? I have
setup
global
volatile pointers to this area.
How are you “reading” the time? If you’re calling time() or
ctime()
etc
you’ll see in the documentation that they are not interrupt
safe.
You can try accessing the realtime clock through raw assembler
calls
or
if you’re on Pentium III you might be able to access a special
register
that just increments, do some math and calulate the time.
-Adam
\