home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11808 < prev    next >
Encoding:
Text File  |  1993-01-05  |  2.3 KB  |  49 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jato!math.jpl.nasa.gov!vsnyder
  3. From: vsnyder@math.jpl.nasa.gov (Van Snyder)
  4. Subject: Re: What is the timer chip clock rate?
  5. Message-ID: <1993Jan5.192626.16123@jato.jpl.nasa.gov>
  6. Sender: nobody@jato.jpl.nasa.gov
  7. Nntp-Posting-Host: math.jpl.nasa.gov
  8. Organization: Jet Propulsion Laboratory
  9. Date: Tue, 5 Jan 1993 19:26:26 GMT
  10. Lines: 37
  11.  
  12. Yesterday I posted:
  13. >In the process of writing a routine to get high-resolution times from the PC's
  14. >timer chip, I wondered at the weird clock rate for the timer chip: 1.193180
  15. >Mhz.  Is that right?  If the clock rate were 1.193046 Mhz, the low-speed
  16. >counter at 040:06eH would tick once per hour.  At 1.193180 Mhz, it ticks about
  17. >1/2 second early (65536*65536/1193180 ~= 3599.597, 65536*65536/1193046 ~=
  18. >3600.001), or about 6 us early per interrupt (65536/1193046-65536/1193180),
  19. >assuming overflow of the medium-speed counter at 040:06cH is intended to tick
  20. >the low-speed counter at 040:06eH once per hour.
  21. >
  22. >The counter in the timer runs continuously, that is, it doesn't stop when it
  23. >generates an interrupt and wait to be restarted, so it doesn't seem reasonable
  24. >that the approximately 6 us per interrupt are to allow for interrupt
  25. >processing.
  26. >
  27. >Also, it seems the only thing one can do if one detects that the timer
  28. >overflow interrupt pending bit is set in the peripheral interrupt controller
  29. >(PIC 0, bit 0) is to pretend the count in the timer chip is 0.  If you
  30. >enable interrupts, do a few NOP's, and start over (which disables
  31. >interrupts), or keep track of the presence or absence of overflow, and add
  32. >that onto the reported medium-speed counter (with carry into the reported
  33. >value from the low-speed counter), the clock occasionally appears to
  34. >run backward by about 20 ms.
  35. >
  36. >Any ideas.
  37.  
  38. I let a timer program, based on hrtime (Dobbs 1992 sep), which I thought
  39. worked just fine, run all night.  The clock backed up once at midnight
  40. (of course), and once again at about 09:00, about 21.5 ms.  This is not
  41. one tick of the medium speed counter at 40:6c, nor 1/2 tick, which is
  42. 27.5 ms.  So does anybody have, or know of, a reliable high-resolution
  43. and moderately long-duration (more than ~50 ms) timer routine?
  44.  
  45. Thanks in advance.
  46. -- 
  47. What fraction of Americans believe   |  Van Snyder
  48. Wrestling is real and NASA is fake?  |  vsnyder@math.jpl.nasa.gov
  49.