* RE: [ECOS] clock_settime() help
@ 2004-10-28 17:39 Jay Foster
2004-10-28 21:20 ` Sam Pham
0 siblings, 1 reply; 5+ messages in thread
From: Jay Foster @ 2004-10-28 17:39 UTC (permalink / raw)
To: 'Sam Pham', eCos Discuss
Perhaps you should use cyg_libc_time_settime() instead. I have not had any
problems using this to set the system time of day. This does require a
wallclock package to be included in your configuration
(CYGPKG_IO_WALLCLOCK). You can use the default wallclock emulation device.
Jay
-----Original Message-----
From: Sam Pham [mailto:anhmn@yahoo.com]
Sent: Thursday, October 28, 2004 9:55 AM
To: eCos Discuss
Subject: [ECOS] clock_settime() help
Hi all,
I'm having trouble with calling the clock_settime()
function. My application has the need of setting the
clock to the current time. At first, I called
clock_settime() inside my ISR, and then outside of
this ISR, I called clock_gettime() to verify if the
current time was set. I noticed that sometimes
clock_settime() failed because clock_gettime()
returned a non-current time value. So I decided to
call clock_settime() in a thread with all interrupts
disabled by calling function cyg_interrupt_disable().
However, I still observed the same failure as before.
Could anyone explain to me how I should be using
function clock_settime()? Its implementation is very
simple - just change the counter value. However, it
looks like if the kernel is in certain states, then it
won't allow anything to change this counter value.
Thanks.
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] clock_settime() help
2004-10-28 17:39 [ECOS] clock_settime() help Jay Foster
@ 2004-10-28 21:20 ` Sam Pham
2004-10-29 10:00 ` sandeep
0 siblings, 1 reply; 5+ messages in thread
From: Sam Pham @ 2004-10-28 21:20 UTC (permalink / raw)
To: Jay Foster, eCos Discuss
Thanks for your response. My application needs to
have timestamp of milli-seconds resolution. Wallclock
is only seconds.
--- Jay Foster <jay.foster@systech.com> wrote:
> Perhaps you should use cyg_libc_time_settime()
> instead. I have not had any
> problems using this to set the system time of day.
> This does require a
> wallclock package to be included in your
> configuration
> (CYGPKG_IO_WALLCLOCK). You can use the default
> wallclock emulation device.
> Jay
>
> -----Original Message-----
> From: Sam Pham [mailto:anhmn@yahoo.com]
> Sent: Thursday, October 28, 2004 9:55 AM
> To: eCos Discuss
> Subject: [ECOS] clock_settime() help
>
>
> Hi all,
>
> I'm having trouble with calling the clock_settime()
> function. My application has the need of setting
> the
> clock to the current time. At first, I called
> clock_settime() inside my ISR, and then outside of
> this ISR, I called clock_gettime() to verify if the
> current time was set. I noticed that sometimes
> clock_settime() failed because clock_gettime()
> returned a non-current time value. So I decided to
> call clock_settime() in a thread with all interrupts
> disabled by calling function
> cyg_interrupt_disable().
> However, I still observed the same failure as
> before.
>
> Could anyone explain to me how I should be using
> function clock_settime()? Its implementation is
> very
> simple - just change the counter value. However, it
> looks like if the kernel is in certain states, then
> it
> won't allow anything to change this counter value.
>
> Thanks.
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We
> finish.
> http://promotions.yahoo.com/new_mail
>
> --
> Before posting, please read the FAQ:
> http://ecos.sourceware.org/fom/ecos
> and search the list archive:
> http://ecos.sourceware.org/ml/ecos-discuss
>
> --
> Before posting, please read the FAQ:
> http://ecos.sourceware.org/fom/ecos
> and search the list archive:
> http://ecos.sourceware.org/ml/ecos-discuss
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] clock_settime() help
2004-10-28 21:20 ` Sam Pham
@ 2004-10-29 10:00 ` sandeep
2004-11-01 16:08 ` Sam Pham
0 siblings, 1 reply; 5+ messages in thread
From: sandeep @ 2004-10-29 10:00 UTC (permalink / raw)
To: Sam Pham; +Cc: Jay Foster, eCos Discuss
Sam Pham wrote:
>>clock to the current time. At first, I called
>>clock_settime() inside my ISR, and then outside of
>>this ISR, I called clock_gettime() to verify if the
>>current time was set. I noticed that sometimes
>>clock_settime() failed because clock_gettime()
>>returned a non-current time value. So I decided to
>>call clock_settime() in a thread with all interrupts
>>disabled by calling function
>>cyg_interrupt_disable().
>>However, I still observed the same failure as
>>before.
some very dumb questions -
- what do you mean by that clock_settime failed??
- when you say "clock_gettime()returned a non-current time value", you mean it
returned a value lesser or more than current time?
- how do you find current time? is your order
clock_gettime
get current time
compare them
OR
get current time
clock_gettime
compare them
- if above are your steps, have you tried doing these under disabled interrupts
and found same results? i am not talking of clock_settime with disabled
interrupts, here.
sandeep
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] clock_settime() help
2004-10-29 10:00 ` sandeep
@ 2004-11-01 16:08 ` Sam Pham
0 siblings, 0 replies; 5+ messages in thread
From: Sam Pham @ 2004-11-01 16:08 UTC (permalink / raw)
To: sandeep; +Cc: Jay Foster, eCos Discuss
Thanks for your response. I've found the bug in my SW
that causes clock_settime() to fail at times. I
didn't normalize the nanosecond field before calling
this function (e.g. if number of nanoseconds >
1000000000, then I need to increment number of seconds
by 1 and decrement number of nanoseconds by
1000000000).
--- sandeep <shimple0@yahoo.com> wrote:
> Sam Pham wrote:
>
> >>clock to the current time. At first, I called
> >>clock_settime() inside my ISR, and then outside of
> >>this ISR, I called clock_gettime() to verify if
> the
> >>current time was set. I noticed that sometimes
> >>clock_settime() failed because clock_gettime()
> >>returned a non-current time value. So I decided
> to
> >>call clock_settime() in a thread with all
> interrupts
> >>disabled by calling function
> >>cyg_interrupt_disable().
> >>However, I still observed the same failure as
> >>before.
>
> some very dumb questions -
>
> - what do you mean by that clock_settime failed??
> - when you say "clock_gettime()returned a
> non-current time value", you mean it
> returned a value lesser or more than current time?
> - how do you find current time? is your order
> clock_gettime
> get current time
> compare them
> OR
> get current time
> clock_gettime
> compare them
>
> - if above are your steps, have you tried doing
> these under disabled interrupts
> and found same results? i am not talking of
> clock_settime with disabled
> interrupts, here.
>
> sandeep
>
>
> --
> Before posting, please read the FAQ:
> http://ecos.sourceware.org/fom/ecos
> and search the list archive:
> http://ecos.sourceware.org/ml/ecos-discuss
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] posix time functions
@ 2004-10-25 14:55 Nick Garnett
2004-10-28 17:25 ` [ECOS] clock_settime() help Sam Pham
0 siblings, 1 reply; 5+ messages in thread
From: Nick Garnett @ 2004-10-25 14:55 UTC (permalink / raw)
To: David Brennan; +Cc: eCos Discuss
David Brennan <eCos@brennanhome.com> writes:
> Nick Garnett wrote:
> >Using the PIT to keep track of real time over a long period is hard
> >since it runs at a very awkward frequency -- although I believe it is
> >reasonably accurate at a 200Hz interrupt rate. It is OK for handling
> >timing requirements of less that a minute or so.
> >
> Yes the problem is with that awkward frequency. I don't have the math
> handy, but we calculated that if we set the PIT to an interrupt rate
> of 1kHz, we would end up off by about 180 mSec per hour. Our system
> actually has multiple computers which generate messages with
> "real-time" time stamps which are often compared with each other for
> diagnostic purposes. So we need mSec accuracy on those messages.
Of course this is the sort of thing that the numerator/denominator
representation of the clock resolution is meant to deal with. The idea
is to adjust those values to more accurately represent the interrupt
frequency the hardware actually gives you, rather than the
approximation used to calculate the timer period. The result is that
eCos ticks end up slightly shorter than 1ms and you don't get the
drift.
> >Does your i386 platform have the standard Dallas RTC device? If so
> >then you could use that to track real time more accurately. The Dallas
> >device also provides a 1KHz interrupt which is more accurate than the
> >PIT, and is synchronized to the real time clock. It may be easier to
> >add an option to switch the eCos timer over to using that.
> >
> >
> >
> Really? I did not think the Dallas chip could interrupt that
> quickly. (I thought it was on the order of 1 Hz).
Specifically it generates a 1024Hz interrupt. However, since there is
no underying fast counter, you cannot do timing more accurately than
that, for hal_delay_us() for example, so it is not a good choice for
the main eCos timer.
> However, I will
> still need to be able to set the clock without affecting any of the OS
> timers.
If you can sort out the timer frequency, then you should only really
need to set it once at startup, before any timeouts are started. If
you use the RTC then you may not need to set it at all.
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ECOS] clock_settime() help
2004-10-25 14:55 [ECOS] posix time functions Nick Garnett
@ 2004-10-28 17:25 ` Sam Pham
0 siblings, 0 replies; 5+ messages in thread
From: Sam Pham @ 2004-10-28 17:25 UTC (permalink / raw)
To: eCos Discuss
Hi all,
I'm having trouble with calling the clock_settime()
function. My application has the need of setting the
clock to the current time. At first, I called
clock_settime() inside my ISR, and then outside of
this ISR, I called clock_gettime() to verify if the
current time was set. I noticed that sometimes
clock_settime() failed because clock_gettime()
returned a non-current time value. So I decided to
call clock_settime() in a thread with all interrupts
disabled by calling function cyg_interrupt_disable().
However, I still observed the same failure as before.
Could anyone explain to me how I should be using
function clock_settime()? Its implementation is very
simple - just change the counter value. However, it
looks like if the kernel is in certain states, then it
won't allow anything to change this counter value.
Thanks.
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-11-01 16:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-28 17:39 [ECOS] clock_settime() help Jay Foster
2004-10-28 21:20 ` Sam Pham
2004-10-29 10:00 ` sandeep
2004-11-01 16:08 ` Sam Pham
-- strict thread matches above, loose matches on Subject: below --
2004-10-25 14:55 [ECOS] posix time functions Nick Garnett
2004-10-28 17:25 ` [ECOS] clock_settime() help Sam Pham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).