This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: # ticks per second?
- To: Andreas dot Karlsson at combitechsystems dot com
- Subject: Re: [ECOS] # ticks per second?
- From: Jonathan Larmour <jlarmour at redhat dot com>
- Date: Wed, 30 Aug 2000 17:15:16 +0100
- CC: ecos-discuss at sourceware dot cygnus dot com
- Organization: Red Hat UK Ltd.
- References: <2253171AF143D21185A60000F8FA748B0229A938@pluto.combitech.se>
Andreas.Karlsson@combitechsystems.com wrote:
>
> Is this rows correct to obtain the number of ticks per second? I want some
>
> timers to go off after some seconds.
>
> /Andreas
>
> cyg_resolution_t clock_res;
>
> cyg_handle_t clock_handle;
>
> cyg_uint32 sec;
>
> clock_handle=cyg_real_time_clock();
>
> clock_res=cyg_clock_get_resolution(clock_handle);
>
> sec=(clock_res.divisor/clock_res.dividend)*1000000000; //dividend/divisor?
Yes, although you run the risk of underflow: divisor would typically be
something like 100 whereas dividend would be 1E9. So try using:
unsigned long long lltmp;
tmp = (clock_res.divisor*1000000000)/clock_res.dividend;
sec = tmp;
Jifl
--
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow." || These opinions are all my own fault