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.
To set the rate at which channel 0 of the timer fires off an IRQ0, we must use our outportb function to write to I/O ports. There is a Data register for each of the timer's 3 channels at 0x40, 0x41, and 0x42 respectively
I have read the 82c54 datasheet, I can not understand why it's the port 0x40,0x41,0x42,0x43 to be programmed.
Because it is the port used by the PIT. that's how internally they are wired.
Every book with the name "80x86 and harware interfacing". Because there is a dozens of books i couldn't remember those author names.
that's why you have to study the datasheets along with them. that's why there is hardly no information on specific motherboards, soundcards etc. PIT seems to be generalized. It is found in almost all the computers. What if the computer have a different Timer circuit?
I can't remember where I found this info but channel 1 is the one you want. Channel 2 is no longer in use and channel 3 is wired to the internal speaker.
What is that meant by channel 2 is no longer in use. I found the same in bkerndev. You can use whatever counter you want, provided that you set the bits correctly in command registers. Nobody is trying to learn PIT. There are lot of modes you can use. But most probably people are using 1 or 2 modes only. Hey i also don't want to learn this thing but it is on my syllabus. I was forced to draw timing diagrams for all 6 modes. But i hardly remember those timing circuits now.
simply because other modes are neither suitable nor becessary for the things that we are doing. for example, the square wave auto reload mode is the one you need in order to produce sound through speaker. you shouldn't use the channel in, let's say mode 1, because that is not you do in order to produe a sound (you can definitely use that mode to generate some sound, but the waveform will not be uniform). And all those timing diagrams that we have drawn in our exams, u will need to use them if u are designing robotic devices, not in our case.
it is a good idea to understand how the interfacing internaly works. eg. in PIT's case, which address line combination chooses which channel, registers etc,
BTW, do you really think that it is necessary to learn PIT, all it's modes along with timing diagrams; to get it working for your OS? The PCs that we generally use have the fixed wiring, and probably won't change in near future. learning which channels are wired to which lines, and the modes that they can be, and are to be programmed in, is, IMHO, enough, the only exception being some different timer arch, or your own fabricated motherboard.
asmboozer wrote:
I have read the 82c54 datasheet, I can not understand why it's the port 0x40,0x41,0x42,0x43 to be programmed.
That's because the datasheet talk about the chip : a generic timer generator. you'll see things such as "when SEL=3, register accessed is command register".
Considering how the chip is wired with the ISA bus, interrupt controller, etc. it comes that accessing I/O port 0x43 activates the chip and sets SEL=3, and things alike.
Correct me if I am wrong, but the 3 channels have very specific uses and are hard wired to perform certain functions. You cannot just use any channel for any purpose.
Channel 1 is wired to IRQ0.
Channel 2 was used to refresh dynamic RAM periodically, but this is now handled internally by the RAM controller. This channel is now disconnected.
Channel 3 is wired directly to the internal speaker so setting channel 3 to a square wave at 1kHz produces a 1kHz tone from the speaker.
Again, I can't remember where I found this so I may be wrong, this is just from memory.
@asmboozer:
RBIL is the Ralf Brown Interrupts List and is one of the most useful bits of info you will read.