Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!ico!rcd From: rcd@ico.isc.com (Dick Dunn) Newsgroups: comp.unix.sysv386 Subject: Re: 8254 timer usage under Sys V/386 R3.2? Message-ID: <1991Feb1.202411.9033@ico.isc.com> Date: 1 Feb 91 20:24:11 GMT References: <16808@ogicse.ogi.edu> Distribution: na Organization: Interactive Systems Corporation, Boulder, CO Lines: 47 apfiffer@admin.ogi.edu (Andy Pfiffer) writes: > I'd like to be able to program and poll one of the timers on the 8254 > Programmable Interval Timer under a vanilla System V/386 R3.2. I have > no difficulty accessing the ports, but I'm not certain how UNIX uses them. There really isn't a timer you can use without screwing things up. For two of them, it's not so much how UNIX uses them as how the hardware uses them. > There are three 1.19 MHz timers on the chip... Yeah...there's actually one crystal-controlled oscillator driving all three CLK inputs on the 8254. The frequency is 1.193182 MHz. (Some AT tech refs are imprecise on this; it does matter for how you program it if you want an accurate clock.) >...My guesses:... > 0 100Hz clock interrupt > 1 DRAM refresh (about 66 KHz) > 2 beep & buzz > Are these correct? Yes. Note that timer 1 is set up for the 15 us cycle and wired on the motherboard to drive refresh...so although you probably can reprogram it (tho I've never done it--at least not that I know of:-), you're asking for trouble. In the same vein, timer 2 is wired to the speaker driver, so if you fiddle with it, you'll make funny noises--and if something decides it needs to honk at the user, the kernel will reprogram the timer out from under you. There's no hardware magic to timer 0 other than wiring CLK OUT 0 to IRQ0. But you're right that UNIX uses it for the system clock, so if you go reprogramming it, you're going to time-warp your system. Even if you don't mind your clock running funny, there are other dangers in repro- gramming it: If you turn it off, kernel timeouts won't happen and you'll probably hang the system in short order. If you crank it way up, clock interrupts will happen too fast and, I'd guess, you'll spend all your time in the kernel trying to handle them; you might manage to panic it. It's unfortunate that there isn't a free timer for other uses. It would be very useful for both system and application tasks. It would be nice if there were a simple I/O card with a programmable timer or two...couldn't take more than a few chips. Does anyone know if such an animal exists? -- Dick Dunn rcd@ico.isc.com -or- ico!rcd Boulder, CO (303)449-2870 ...Mr. Natural says, "Use the right tool for the job."