Page 1 of 1

[Solved] 1000 PIT interrupts a second?

Posted: Wed Jan 29, 2014 11:37 pm
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

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:16 am
by VolTeK
Id imagine its 0 - 60 time is in here somewhere http://wiki.osdev.org/PIT

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:26 am
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 ;)

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:29 am
by Combuster
;Input
; ebx Desired PIT frequency in Hz
I mean, seriously?

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:30 am
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

[Solved] Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:37 am
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. :)

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:47 am
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

Re: 1000 PIT interrupts a second?

Posted: Thu Jan 30, 2014 12:48 am
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