matt@srs.uucp (Matt Goheen) (09/01/89)
I have a need (and some of the necessary will power) to create a timing routine on a PC that has 1ms accuracy. Whipping out a trusty Intel book with the functional description of the 8253, and browsing through one of the various Peter Norton books, I find that the 8253 in IBM PCs ticks away at 1.193180 MHz and that the channel 0 counter drives the system clock tick via interrupt 0x8 which, in turn, increments a four byte quantity at 40:6c (note that this is the "low-down" approach, calling the Microsoft-C _bios_whatever() to get the ticks would work fine as well, there are MANY ways to do the same thing). So, I read the system tick count, which gets incremented 1193180/65536 times per second (about 18.2), and I latch the count in the 8253 and read that out. Trouble is, it appears that the 8253 only interrupts the PC I am using every OTHER time it exhausts its count!!! The PC I'm trying this on is a Dell 386 machine of some sort. What I'm wordering is if this is the way it works on other PCs as well. Naturally, the problem here is that it is impossible for me to know when the 8253 exhausts its count and doesn't increment the clock tick count (unless I just loop looking at it, but then I can't time some other event that way). That sorta sucks (ahh, welcome to the land that time forgot -- the wonderful world of PCs!). I suppose I can change the countdown amount for channel 0 of the 8253 and make it interrupt alot more often, but to get even close to 1ms accuracy, I would have to change the count from 65536 to something like 1024 (about 1200 interrupts/sec, and the accuracy wouldn't be all that great even at that rate). Any ideas? Please MAIL them to me as we don't save this group for more than about 24 hours, and I don't have the time to read it. Thanks Folks, Matt Goheen matt@srs.uucp -- - uucp: {rutgers,ames}!rochester!srs!matt Matt Goheen - - internet: matt@srs.uucp OR matt%srs.uucp@harvard.harvard.edu - - "We had some good machines, but they don't work no more." -