public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Clocks on EDB7XXX
@ 2001-07-17 10:40 Trenton D. Adams
  2001-07-17 11:39 ` Gary Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Trenton D. Adams @ 2001-07-17 10:40 UTC (permalink / raw)
  To: 'eCos Discussion'

Ok, the RTC on this platform is 1Hz.  If I use cyg_clock_create () will
it always work with the resolution I pass to it?  I want to be able to
get a clock based on ms rather than seconds.  Also is there a way of
getting the uptime of the system in ms?

What I actually need is a way of getting an accurate time in ms.  I was
thinking of doing the following.

On startup do the following
Store the current clock tick value in an initial clock tick variable.
Ultimately I would like this to be in ms and not necessarily clock
ticks.
Store the RTC value in an initial RTC variable

Calculating RTC seconds + ms of time. 
Since the RTC is in seconds, I have to make sure the tick variable
before is synchronized with the RTC so 0 ms is at the right time (same
time as an RTC increment).

RTC - RTC variable = seconds since startup

Get tick count
ms = (tick count - tick variable) - seconds since startup * 1000

ms would then be the correct number of milliseconds after the last RTC
increment occurred.

Is there an easier way of doing this in eCos?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [ECOS] Clocks on EDB7XXX
  2001-07-17 10:40 [ECOS] Clocks on EDB7XXX Trenton D. Adams
@ 2001-07-17 11:39 ` Gary Thomas
  2001-07-17 12:56   ` Trenton D. Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Gary Thomas @ 2001-07-17 11:39 UTC (permalink / raw)
  To: Trenton D. Adams; +Cc: eCos Discussion

On 17-Jul-2001 Trenton D. Adams wrote:
> Ok, the RTC on this platform is 1Hz.  If I use cyg_clock_create () will
> it always work with the resolution I pass to it?  I want to be able to
> get a clock based on ms rather than seconds.  Also is there a way of
> getting the uptime of the system in ms?
> 
> What I actually need is a way of getting an accurate time in ms.  I was
> thinking of doing the following.
> 
> On startup do the following
> Store the current clock tick value in an initial clock tick variable.
> Ultimately I would like this to be in ms and not necessarily clock
> ticks.
> Store the RTC value in an initial RTC variable
> 
> Calculating RTC seconds + ms of time. 
> Since the RTC is in seconds, I have to make sure the tick variable
> before is synchronized with the RTC so 0 ms is at the right time (same
> time as an RTC increment).
> 
> RTC - RTC variable = seconds since startup
> 
> Get tick count
> ms = (tick count - tick variable) - seconds since startup * 1000
> 
> ms would then be the correct number of milliseconds after the last RTC
> increment occurred.
> 
> Is there an easier way of doing this in eCos?

Yes.  Use the system clock, which will have a 10ms resolution by default,
and the function HAL_CLOCK_READ() which can be used to calculate the time
relative to the current 'tick'.  Using this method, you can have times
as accurate as the hardware supports (on the Cirrus Logic EDB7xxx down
to 2us).

What this does _not_ provide is any way to schedule threads on a higher
resolution basis, but it doesn't seem like that's what you were after.

[Shameless repeated plug] You'll find code which does all of this and 
makes use of such high resolution numbers in the kernel test tm_basic.cxx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [ECOS] Clocks on EDB7XXX
  2001-07-17 11:39 ` Gary Thomas
@ 2001-07-17 12:56   ` Trenton D. Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Trenton D. Adams @ 2001-07-17 12:56 UTC (permalink / raw)
  To: 'Gary Thomas'; +Cc: 'eCos Discussion'

  > On 17-Jul-2001 Trenton D. Adams wrote:
  > > Ok, the RTC on this platform is 1Hz.  If I use cyg_clock_create ()
  > will
  > > it always work with the resolution I pass to it?  I want to be
able to
  > > get a clock based on ms rather than seconds.  Also is there a way
of
  > > getting the uptime of the system in ms?
  > >
  > > What I actually need is a way of getting an accurate time in ms.
I
  > was
  > > thinking of doing the following.
  > >
  > > On startup do the following
  > > Store the current clock tick value in an initial clock tick
variable.
  > > Ultimately I would like this to be in ms and not necessarily clock
  > > ticks.
  > > Store the RTC value in an initial RTC variable
  > >
  > > Calculating RTC seconds + ms of time.
  > > Since the RTC is in seconds, I have to make sure the tick variable
  > > before is synchronized with the RTC so 0 ms is at the right time
(same
  > > time as an RTC increment).
  > >
  > > RTC - RTC variable = seconds since startup
  > >
  > > Get tick count
  > > ms = (tick count - tick variable) - seconds since startup * 1000
  > >
  > > ms would then be the correct number of milliseconds after the last
RTC
  > > increment occurred.
  > >
  > > Is there an easier way of doing this in eCos?
  > 
  > Yes.  Use the system clock, which will have a 10ms resolution by
  > default,
  > and the function HAL_CLOCK_READ() which can be used to calculate the
  > time
  > relative to the current 'tick'.  Using this method, you can have
times
  > as accurate as the hardware supports (on the Cirrus Logic EDB7xxx
down
  > to 2us).
  > 
  > What this does _not_ provide is any way to schedule threads on a
higher
  > resolution basis, but it doesn't seem like that's what you were
after.
  > 

Yes, that is correct.  I have no need for a higher resolution scheduler.

  > [Shameless repeated plug] You'll find code which does all of this
and
  > makes use of such high resolution numbers in the kernel test
  > tm_basic.cxx

What's a repeated plug?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-17 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-17 10:40 [ECOS] Clocks on EDB7XXX Trenton D. Adams
2001-07-17 11:39 ` Gary Thomas
2001-07-17 12:56   ` Trenton D. Adams

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).