Page 1 of 1
PIT get counter frequency
Posted: Wed Jul 31, 2013 8:39 am
by MadZarx
Hello. How is it possible to get one of the PIT's counters frequency? I mostly need the 1st and 3rd counter frequencies. I know I can use a variable to store the frequency but I just want to have a very small kernel in size
(Of course my bootloader is 17KiBs) And the kernel itself is less than 6KiBs with a reach console controller and Interrupts enabled!
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 9:12 am
by iansjack
The frequency is whatever you set it to. And, let's face it, it's going to take less bytes to store this in a variable than any routine to read this from the chip would.
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 9:18 am
by MadZarx
I know. But it would be perfect to use inb or outb to read the frequency of a counter. Is it possible?
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 9:46 am
by iansjack
No, you cannot read the reset count value, just the current count. No doubt Intel thought, for the reason I outlined earlier, that is was an unnecessary facility. Were it possible it would require at least one write to the control register and two reads from the data register. This would take more bytes of code, and would no doubt be slower, than retrieving the value from a variable.
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 9:50 am
by Nessphoro
PIT always starts up with a predefined frequency of around 18Hz
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 10:10 am
by MadZarx
Okay thank you guys
So its better to use variables in this situation cuz speed is more important than size
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 10:17 am
by iansjack
It's not a question of speed versus size. In this case it's just not possible. And were it possible it would be worse in terms of both speed and size.
Re: PIT get counter frequency
Posted: Wed Jul 31, 2013 11:18 am
by MadZarx
Okay thanks iansjack