What is wrong with Pit?

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
Parker

What is wrong with Pit?

Post 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?
Curufir

Re:What is wrong with Pit?

Post 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.
DynatOS

Re:What is wrong with Pit?

Post 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
Post Reply