delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/05/29/23:27:08

Message-ID: <3ED6CF29.5060803@bigpond.com>
Date: Fri, 30 May 2003 13:25:29 +1000
From: Ben Peddell <killer DOT lightspeed AT bigpond DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: DJ Delorie <dj AT delorie DOT com>
CC: djgpp-workers AT delorie DOT com
Subject: Re: uclock() still out by 1 in 65536
References: <4wyBa.45993$1s1 DOT 615094 AT newsfeeds DOT bigpond DOT com> <200305300208 DOT h4U28vDV031441 AT envy DOT delorie DOT com> <3ED6C0EB DOT 3080403 AT bigpond DOT com> <200305300229 DOT h4U2T5vd031704 AT envy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

DJ Delorie wrote:

>Please keep djgpp-workers on the recipient list.
>  
>
Sorry. I was using the Reply button instead of the Reply All button.

>  
>
>>>If the count's wrong, it's a bug.  The question is - are we *supposed*
>>>to be counting to 65535, or 65536?  IIRC there are some oddities in
>>>how the timer works.
>>>
>>> 
>>>
>>>      
>>>
>>Well, the code programs a count of 65535:
>>
>>    outportb (0x43, 0x34);
>>    outportb (0x40, 0xFF);
>>    outportb (0x40, 0xFF);
>>
>>whilst it assumes a count of 65536:
>>
>>    rv = ((uclock_t)tics << 16) | (msb << 8) | lsb;
>>
>>I'll check it on the real PIT, and get back to you.
>>

OK. It does work. There was a jitter of about 1us when comparing it to 
RDTSC.

>>    
>>
>
>No, my question was whether a count of 65535 was required to get the
>total tic count correct for a day.
>
>  
>
uclock() assumes 0x1800B0 tics in a day.

There are 1193180*86400/65536 = 1573040.04 (0x1800B0) tics in an day.

With a timer period of 65535, it would have 1573064.04 (0x1800C8) tics 
in a day.
It would gain one full tic per hour, and would be out by 1.5 seconds at 
the end of the day.

Thankyou for your great tools.
Ben




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019