[ECOS] Timer tick length

Grant Edwards grante@visi.com
Tue Apr 4 13:48:00 GMT 2000

On Tue, Apr 04, 2000 at 12:33:59PM -0600, Gary Thomas wrote:

> The information _is_ there, it's just not pretty.
> Here's how to get at it (culled from ecc/kernel/XXX/tests/tm_basic.cxx):
>   #include <pkgconf/kernel.h>
>   long rtc_resolution[] = CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION;
>   long ns_per_system_clock;
>   // To convert system clock 'ticks' to nanoseconds (ns)
>   ns_per_system_clock = 1000000/rtc_resolution[1];
>   ns = (ns_per_system_clock * (long long)ticks) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;


Jonathan Larmour <jlarmour@redhat.co.uk> wrote:
> Actually there's something even more relevant in <cyg/kernel/clock.hxx> for
> the Cyg_Clock class:


> struct pcc;
> cyg_tick_count ns_per_tick;
> Cyg_Clock::real_time_clock->get_clock_to_other_convertor( 1, &pcc);
> ns_per_tick = Cyg_Clock::convert(1, &pcc);
> Looking at the clockcnv.cxx test may help too, but that'salso a bitt
> esoteric :). Have a play...

While it looks like both of these could be made to work, I
think there is a need for a macro that can be used to create a
compile-time constant that represents the number of ticks
required for a specified period of time -- something that could
be used inside an ISR without worrying about the execution
speed, or could be used as a static initializer.

Grant Edwards

More information about the Ecos-discuss mailing list