Page 1 of 1

What is wrong with Pit?

Posted: Fri Sep 05, 2003 9:46 am
by Parker
I want my IRQ 0 to be raised only one times a second. Here is my code:

Code: Select all

word cnt=1193180;

out(0x43, 0x36);
out(0x40,(unsigned char) (cnt));
out(0x40,(unsigned char) (cnt >> 8));

setIDTEntry(PitISR, 0x20; 0x0e + 0x80 + 0x60);
EnableIRQ(0);
But my PitISR called lots of times a second. I can not slow it down, although changing cnt value. Am I doing something wrong??? What sould the correct code be to make my PitISR be called only ones a second?

Re:What is wrong with Pit?

Posted: Fri Sep 05, 2003 11:02 am
by Curufir
You can't have IRQ0 called 1 time per second. The maximum value for the counter is 65535 which results in a rate of 18.2 interrupts/second.

Re:What is wrong with Pit?

Posted: Thu Sep 11, 2003 10:58 am
by DynatOS
For every 1024 cycles, have the code you want to be executed by the PIT executed.

// PIT
counter ++;
if (counter == 1024) {
counter = 0;
//execute this
}
// END PIT