PIT programming
PIT programming
Hi. I want to learn PIT programming. But i don't have a document. I search at google. But documents aren't advanced. Where can i found documents about pit programming?
Re:PIT programming
There are plenty as I see it. From what I can find in a couple of minutes:
http://www.mega-tokyo.com/osfaq/PIT
http://heim.ifi.uio.no/~stanisls/helppc/8253.html
http://kos.enix.org/pub/82C54_PIT_Datasheet.pdf
http://en.wikipedia.org/wiki/8254
Try using 8254 in your search terms, like "8254 pit" minus the quotes.
http://www.mega-tokyo.com/osfaq/PIT
http://heim.ifi.uio.no/~stanisls/helppc/8253.html
http://kos.enix.org/pub/82C54_PIT_Datasheet.pdf
http://en.wikipedia.org/wiki/8254
Try using 8254 in your search terms, like "8254 pit" minus the quotes.
Re:PIT programming
My PIT doesn't run. I only remapped irqs. Can the problem be that irq0 disabled?
Re:PIT programming
It could be masked in the PIC, I'm assumming your using the legacy 8259A controller which can be unmasked something like:Tolga wrote: My PIT doesn't run. I only remapped irqs. Can the problem be that irq0 disabled?
Code: Select all
mov al, 11111010b ; mask all but IRQ-0 & IRQ-2 (cascade)
out 021h, al
mov al, 11111111b ; mask all in slave
out 0A1h, al
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re:PIT programming
No documents i've read say something about the mask register being set or cleared after a reprogram, so possibly its left masked.
However, my boxes have the irq's unmasked after the reprogram, and honestly i never cared to check if they are beforehand. However its good practice to always set the mask, who knows what dodgy boards are out.
I figured a thing or two while trying to get the PIT produce IRQ's at regular intervals
some things i figured over time:
- the PIT might not be preset by the bios to rate generator
- the PIT will only start counting when you wrote the entire count
- forgetting STI (yes, i made that error once, i figured when bochs complained about HLT with IF=0)
Most likely the bios hasnt set the PIT to rate generator for you (i have 2 boxes who put the PIT off-duty and at last 4 who leave them running), so most likely the fault is the bios here
Basically, you have to program the PIT if you want to use it, not just writing an irq0 handler
However, my boxes have the irq's unmasked after the reprogram, and honestly i never cared to check if they are beforehand. However its good practice to always set the mask, who knows what dodgy boards are out.
I figured a thing or two while trying to get the PIT produce IRQ's at regular intervals
some things i figured over time:
- the PIT might not be preset by the bios to rate generator
- the PIT will only start counting when you wrote the entire count
- forgetting STI (yes, i made that error once, i figured when bochs complained about HLT with IF=0)
Most likely the bios hasnt set the PIT to rate generator for you (i have 2 boxes who put the PIT off-duty and at last 4 who leave them running), so most likely the fault is the bios here
Basically, you have to program the PIT if you want to use it, not just writing an irq0 handler
Re:PIT programming
I wrote mask all code.
After this, irq0 is occurring only one times.
setup_channel code
Code: Select all
outport( 0x21, 250 );
outport( 0xA1, 255 );
pit_count = 0;
pit.setup_channel_0( 0xFFFF );
setup_channel code
Code: Select all
void tpit::setup_channel_0( unsigned short frequency )
{
// Variables
unsigned short counter;
// Calculate Counter
counter = 0x1234DD / frequency;
// Setup Mode
outport( 0x43, 0x34 );
// Send Low Count
outport( 0x40, (counter % 256) );
// Send High Count
outport( 0x40, (counter / 256) );
}
Re:PIT programming
EOI is End of interupt.. i thinkTolga wrote: I remapped IRQs to 32 and 40. But I don't know EOI. What is it? :-\
atleast you need this code somewhere in your interupt handler:
mov al,20h
out 20h,al
out 0a0h,al ; < --- this only if IRQ > 7
if you dont do that the PIC will simply wait untill it recieves that command, and if you never send it, then it wont invoke any new IRQ's since its waiting.
Regards
PyroMathic