[comp.sys.ibm.pc.programmer] about reprogramming the timer tick

c162-dr@zooey.Berkeley.EDU (Eric Ng) (05/05/90)

I am writing an application in which it would be advantageous to
reprogram the timer's channel 0 to tick at more than 18.2 times per
second (for argument's sake, let's assume quadruple that rate, 72.8
times per second).

With no Tech Ref (but some Kermit and Freemacs source), I wrangled
out the below code fragment:

   mov dx,0043
   mov al,36	; timer channel 0, low before high, square wave, binary
   out dx,al
   mov dx,0040
   mov al,07	; low byte of 0x4007 = 1,193,280/72.8
   out dx,al
   mov al,40	; high byte of 0x4007
   out dx,al

After executing this code fragment, I notice that I have achieved (at
least partial) success:  the clock runs about four times faster.

In my application I plan to grab the 0x08 interrupt and issue
the old 0x08 interrupt every fourth time through so that the time of
day and other timer-dependent things aren't botched up.  Now, what my
question is, I want to restore the timer channel 0 rate upon exit:
how do I read the original rate from channel 0?  I mean, I can just
assume 18.2, but I'm sure this could lead to problems...  Also, is
there anything that I am doing that is painfully wrong?  I mean, the
above came out of plain guesswork, so I'm assuming that I did
something wrong...

Can anyone who has done this before help me?

Thanks in advance, -eric



--
Eric Ng, 1906 Milvia Street, Berkeley, California 94704
..!ucbvax!irss.njit.edu!erc -or- erc@irss.njit.edu