This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: # ticks per second?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]