PIT Channel 0 Example Code @ Wiki

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Bughunter
Member
Member
Posts: 94
Joined: Mon Dec 18, 2006 5:49 am
Location: Netherlands
Contact:

PIT Channel 0 Example Code @ Wiki

Post 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?
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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.
Author of COBOS
User avatar
Bughunter
Member
Member
Posts: 94
Joined: Mon Dec 18, 2006 5:49 am
Location: Netherlands
Contact:

Post 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?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PIT Channel 0 Example Code @ Wiki

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Bughunter
Member
Member
Posts: 94
Joined: Mon Dec 18, 2006 5:49 am
Location: Netherlands
Contact:

Post by Bughunter »

Thanks :). I will have a look at it when I have some more time.
Post Reply