PIT get counter frequency

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
MadZarx
Member
Member
Posts: 85
Joined: Mon Apr 01, 2013 5:06 am
Location: CMOS :D

PIT get counter frequency

Post 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 :oops: (Of course my bootloader is 17KiBs) And the kernel itself is less than 6KiBs with a reach console controller and Interrupts enabled! :mrgreen: :P
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: PIT get counter frequency

Post 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.
MadZarx
Member
Member
Posts: 85
Joined: Mon Apr 01, 2013 5:06 am
Location: CMOS :D

Re: PIT get counter frequency

Post by MadZarx »

I know. But it would be perfect to use inb or outb to read the frequency of a counter. Is it possible?
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: PIT get counter frequency

Post 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.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: PIT get counter frequency

Post by Nessphoro »

PIT always starts up with a predefined frequency of around 18Hz
MadZarx
Member
Member
Posts: 85
Joined: Mon Apr 01, 2013 5:06 am
Location: CMOS :D

Re: PIT get counter frequency

Post by MadZarx »

Okay thank you guys ;) [-o<
So its better to use variables in this situation cuz speed is more important than size :mrgreen:
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: PIT get counter frequency

Post 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.
MadZarx
Member
Member
Posts: 85
Joined: Mon Apr 01, 2013 5:06 am
Location: CMOS :D

Re: PIT get counter frequency

Post by MadZarx »

Okay thanks iansjack :wink:
Post Reply