www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/10/05/02:46:35

Date: Fri, 30 Sep 94 18:21:22 -0400
From: dj AT stealth DOT ctron DOT com (DJ Delorie)
To: nigel AT algor DOT co DOT uk
Cc: ldoan1 AT mason1 DOT gmu DOT edu, victor AT euler DOT Berkeley DOT EDU,
DJGPP AT sun DOT soe DOT clarkson DOT edu
Subject: Re: accuracy of clock()

> If you do not actually need more frequent interrupts, but just want to
> accurately read the elapsed time, then another way to do it might be
> to leave the timer interrupting at 18.2Hz, but read the timer's count
> register.  By doing this you can calculate how many microsecs have
> passed since the last interrupt, and add that to the interrupt count.

Well, not really.  The timer normally operates in a mode whereby the
count counts from 0..(N/2) *twice* between each interrupt.  This is so
that it can handle odd counts (0..N/2,0..(N+1)/2) with approximately
50% duty cycle.

You have to reprogram the timer to pulse mode, where it *does* count
from 0..N between interrupts.


- Raw text -


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