Page 1 of 1

PIT Channel 0 Example Code @ Wiki

Posted: Sat Jul 07, 2007 12:26 pm
by Bughunter
http://www.osdev.org/mediawiki/index.ph ... ample_Code

I recently setup my exception handlers and I have setup the PIT IRQ.

Now, I was wondering how could I accurately calculate how many fractions of an mS and how many mS should I add to the system timer each time the IRQ fires?

I tried looking at the code example, but for some reason I don't really get why 2^32 and 256 is used everywhere (I do understand why the example uses 3579545/3 though). Maybe coffee level dropped too low or I didn't sleep enough, but I'm not getting it at the moment.

Anyone want to look at it and perhaps post their thoughts?

Posted: Sat Jul 07, 2007 12:37 pm
by os64dev
you dont time with PIT, you do the time the realtime clock. It is designed for it and has a 1ms accuracy. or the local apic for that matter.

Posted: Sat Jul 07, 2007 12:51 pm
by Bughunter
But in many topics I read here, the PIT IRQ is used to measure time. And by reading the code example, I assume the code example uses it for the system timer too?

Btw, any info on how to access the RTC?

Re: PIT Channel 0 Example Code @ Wiki

Posted: Sun Jul 08, 2007 5:55 am
by Brendan
Hi,
bughunter wrote:I tried looking at the code example, but for some reason I don't really get why 2^32 and 256 is used everywhere (I do understand why the example uses 3579545/3 though). Maybe coffee level dropped too low or I didn't sleep enough, but I'm not getting it at the moment.

Anyone want to look at it and perhaps post their thoughts?
I took a look - it was unnecessarily complicated and had some bugs. I fixed the bugs and simplified it a little... ;)


Cheers,

Brendan

Posted: Sun Jul 08, 2007 2:25 pm
by Bughunter
Thanks :). I will have a look at it when I have some more time.