[Solved] 1000 PIT interrupts a second?

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
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

[Solved] 1000 PIT interrupts a second?

Post by PearOs »

Can someone help me configure my PIT to run at 1000 interrupts per second? Or is this even possible? I am having a hard time understanding what frequency it should run at.

Thanks, Matt
Last edited by PearOs on Thu Jan 30, 2014 12:41 am, edited 1 time in total.
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: 1000 PIT interrupts a second?

Post by VolTeK »

Id imagine its 0 - 60 time is in here somewhere http://wiki.osdev.org/PIT
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: 1000 PIT interrupts a second?

Post by PearOs »

VolTeK wrote:Id imagine its 0 - 60 time is in here somewhere http://wiki.osdev.org/PIT
I did a "refresher" on the PIT wiki and I'm not really seeing my answer. I've read that article many times, and of course I read it before I asked my question ;)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 1000 PIT interrupts a second?

Post by Combuster »

;Input
; ebx Desired PIT frequency in Hz
I mean, seriously?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: 1000 PIT interrupts a second?

Post by Brendan »

Hi,
PearOs wrote:Can someone help me configure my PIT to run at 1000 interrupts per second? Or is this even possible? I am having a hard time understanding what frequency it should run at.
The PIT page in the wiki should be enough to figure out how to configure the PIT.

1000 IRQs per second should be entirely possible (as long as nothing in your OS disables IRQs for 1 ms or more).

What frequency it should run at depends on what you use it for and a lot of other things. For example, if you're only using it to keep track of "real time" (and not using it for "nano_sleep()" or scheduling or anything) then it should probably be set to a low frequency (e.g. 100 Hz or 1000 Hz); and if you're not using it to keep track of "real time" (and are using it for "nano_sleep()" and/or scheduling) then you probably shouldn't set it to any frequency at all (e.g. use "one shot mode").


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.
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

[Solved] Re: 1000 PIT interrupts a second?

Post by PearOs »

Ok ok ok calm down. I asked the wrong question ;)

I needed to know how many hertz would be 1000 miliseconds. Haha
Which is 1 miliseconds / 1000 = 0.001
1 second / seconds = hertz which 1 / 0.001 = 1000 hz!
Haha so if I set the pit to a frequency of 1193.18, I get what I want. :)
Last edited by PearOs on Thu Jan 30, 2014 12:51 am, edited 2 times in total.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: 1000 PIT interrupts a second?

Post by Brendan »

Hi,
PearOs wrote:Ok ok ok calm down. I asked the wrong question ;)

I needed to know how many hertz would be 1000 miliseconds. Haha
Which is 1000 miliseconds / 1000 = 1
1 second / seconds = hertz which 1 / 1 = 1 hz!
Haha so if I set the pit to a frequency of 1193180, I get what I want. :)
Um?

1193181.666666 / 1 = 1193181.666666. This won't fit in the 16-bit counter, so you don't get what you want. The closest you will get is a count of 65536, which works out to 54.92541 ms between IRQs (or about 18.2065 Hz). The PIT can't go slower.

If you want 1 millisecond between IRQs, then 1193181.666666 / 1000 = 1193.181666. This will only fit if in a 16-bit counter if you round it to the nearest integer. The closest is a count of 1193, which works out to 1.11094 ms between IRQs (or about 9001.37 Hz). Notice that this is 11% more time between IRQs than you wanted. You don't get what you want.


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.
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: 1000 PIT interrupts a second?

Post by PearOs »

Brendan wrote:Hi,
PearOs wrote:Ok ok ok calm down. I asked the wrong question ;)

I needed to know how many hertz would be 1000 miliseconds. Haha
Which is 1000 miliseconds / 1000 = 1
1 second / seconds = hertz which 1 / 1 = 1 hz!
Haha so if I set the pit to a frequency of 1193180, I get what I want. :)
Um?

1193181.666666 / 1 = 1193181.666666. This won't fit in the 16-bit counter, so you don't get what you want. The closest you will get is a count of 65536, which works out to 54.92541 ms between IRQs (or about 18.2065 Hz). The PIT can't go slower.

If you want 1 millisecond between IRQs, then 1193181.666666 / 1000 = 1193.181666. This will only fit if in a 16-bit counter if you round it to the nearest integer. The closest is a count of 1193, which works out to 1.11094 ms between IRQs (or about 9001.37 Hz). Notice that this is 11% more time between IRQs than you wanted. You don't get what you want.


Cheers,

Brendan
Hahahaha I know I messed up lol, I checked my math. I seriously could use some coffee. Fixed now though.
Thanks Brendan :D
Post Reply