heintze@grane.enet.dec.com (Siegfried Heintze) (10/17/90)
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. (a) What is the address of the countdown register? (b) How do I read the current value and write a new value to this countdown register? I suspect I would use some inport and outport instructions. (c) What is the location of the interupt vector element that holds the address of the clock routine? I would suppose I use one of the MSDOS services to fetch the old value and write the address of my routine. I don't recal which service this is, but I remember seeing an example of this in the TURBO C++ documentation. 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? Thanks much, Sieg
dixon@sagittarius.crd.ge.com (walt dixon) (10/17/90)
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
lsalomo@omni.uucp (Lawrence W Salomon) (10/17/90)
The chip number is 8271 (I think) and you can find it, and most of the other chips in the Intel Reference manual. It gives you all of the information you need to do what you describe, including how to reprogram the chip (although this isn't recommended unless you REALLY know what you're doing). Cheers, Q
tris@alzabo.uucp (Tris Orendorff) (10/18/90)
heintze@grane.enet.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? I recommend the following book: Programmer's Problem Solver for the IBM PC, XT and AT Robert Jourdain 1986 ISBN 0-89303-787-7 It will answer all your questions. -- Sincerely Yours Tris Orendorff tris@alzabo.uucp ----------------------------------------------------------------------- ALGERNON: The doctors found out that Bunbury could not live ... so Bunbury died. LADY BRACKNELL: He seems to have had great confidence in the opinion of his physicians.