Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!sagittarius!dixon From: dixon@sagittarius.crd.ge.com (walt dixon) Newsgroups: comp.sys.ibm.pc.hardware Subject: Re: How to roll my own Clock service routine and emit tones Keywords: timers, speaker, tones Message-ID: <12827@crdgw1.crd.ge.com> Date: 17 Oct 90 12:47:08 GMT References: <16408@shlump.nac.dec.com> Sender: news@crdgw1.crd.ge.com Reply-To: dixon@sagittarius.crd.ge.com (walt dixon) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 55 In <16408@shlump.nac.dec.com> Siegfried Heintze writes: >I have some questions about timers in the IBM PC/AT and its clones. >I wasn't sure if this is a hardware or software question. >(1) What is the name of the chip they use to generate the clock > interrupt every 18.2 ms? >(2) Where can I get documentation on it? >(3) I would like to establish my own clock interupt service routine > that calls the default clock routine at the appropriate intervals by > use of a counter. The purpose of this is to gain control at intervals > with a granularity greater than 18.2 ms. [text deleted] >On a slightly different - but possibly related subject: >(4) How does BORLAND implement their sound and nosound routines in TC++? >These routines allow you to generate a study tone while other CPU > processing is in progress. >(5) How would I write a program that emits an uninterupted tone > whose pitch is controlled by the vertical position of the mouse on > the screen? The PC uses an 8253 counter timer to generate the clock interrupt. One channel of the counter/timer can send a square wave to the speaker. I suspect that this is the way BORLAND implements their sound routines. The clock isr interrupts at IRQ0 which is mapped to interrupt 8 by the 8259 interrupt controller. The best source of information on the 8253 is the component data sheets. The chip itself is made by Intel and second sourced by other vendors. I've described doing something very similar to what you are attempting in Chapter 11 of "The MS-DOS Papers", (Howard Sams, 1988). In that chapter I discuss writing a device driver to play music. Specifically, I speed up the clock by a factor of 16 and use another counter to generate a square wave which is fed to the speaker. There is also a performance analysis of the new clock ISR. If you are speeding up the clock interrupts significantly, its useful to go through an analysis to make sure you have enough CPU cycles. For my application I had plenty of horsepower on an XT with a speedup of 16. BTW I get no revenues from book sales. I'm just citing a good reference. Walt Dixon {internet: dixon@crd.ge.com } {us mail: ge-crd } { po box 8 } { schenectady, ny 12301 } {phone: 518-387-5798 (W) } { 518-875-6203 (H) } Walt Dixon dixon@crd.ge.com