delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/11/05:17:33

Date: Sun, 11 May 1997 12:15:57 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: sams AT nbisrv DOT nbi DOT dk
cc: djgpp AT delorie DOT com
Subject: Re: 16bit timer problems
In-Reply-To: <1997May6.154232.3808@news.nbi.dk>
Message-ID: <Pine.SUN.3.91.970511121212.27751L-100000@is>
MIME-Version: 1.0

On 6 May 1997 sams AT nbisrv DOT nbi DOT dk wrote:

> For a long time I've been using the timer function timer16 below to read 
> the 1193180 Hz timer. It has worked flawlessly, and the test routine main 
> below has always given uncertainty in timing (dtmax) less than 20 micro-
> seconds. 
> However, having bought a new Pentium Pro, I experience problems: 
> I get dtmax of order 27000 microseconds. 
[snip]
> unsigned short timer16()                /* Usage: cli(); timer16(); sti();  */
> {
>   unsigned short sts, lsb, msb, result;
>   do{
>     outportb(0x43,0xc2);
>     sts = inportb(0x40);
>     lsb = inportb(0x40);
>     msb = inportb(0x40);
>     result = (msb<<7) | (lsb>>1);
>   }while(!result);
>   result |= ((sts<<8) & (1<<15)) ;
>   return ~result;                                     /* return 16bit timer */
> }

One possible reason is that you don't wait between outport and inport 
calls, and between inport calls themselves.  Pentium (or even i486, for 
that matter) can run circles around the devices that are referenced 
through the bus.  Chances are that the timer chip cannot cope with two 
instructions without some minimal delay between them.  Try adding a few 
NOPs, or a loop that kills some time and see if that helps.

- Raw text -


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