While I was reading up on the 8254 PIT chip, I had thought it wise to make a header with all the bitmaps for the different parts of the command, that way I could make a really clear init function with somthing along the lines of:
Code: Select all
outb(PIT_CMD, PIT_CHANNEL_0 | PIT_LHBYTE | PIT_MODE_2 | PIT_BIN_MODE);
Now here's where it gets interesting. While I was doing this, I had been looking at the last time I had implemented this feature, which was a blind copy from James Molloy's Kerenl tutorial about 3 years ago. I had noticed that my old code looked like this:
Now, upon looking up the bitmap of that code against my newly made header defines, I noticed somthing that didn't add up; The old code was using a the square wave mode (Mode 3), not the rate generator mode (Mode 2). Now upon further investigation, I had noticed this is the same in both
James' code, and in it's inspiration
bkerndev. Am I missing somthing blaringly obvious here? Is that a typo in their code? Is there one on the wiki? Would this work regardless due to rising edge interrupts on the pic? If someone could shed some light on this, I would be very grateful.
"On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."