Page 1 of 1
timer IRQ
Posted: Tue Feb 25, 2003 12:00 am
by OSNewbie
by default at boot, how often does a timer interrupt (IRQ0) occur? and is it possible to change this?
RE:timer IRQ
Posted: Tue Feb 25, 2003 12:00 am
by carbonBased
18.2 times per second, and yes, you can change it
void timerSetFreq(short freq) {
long counter = PIT_FREQ / freq;
outportb(TIMER_CTRL, /*0x43*/TIMER0 + TIMER_WHOLE + TIMER_MODE2);
outportb(TIMER0_CNTR, counter % 256); // send LSB
outportb(TIMER0_CNTR, counter / 256); // send MSB
return;
}
Where:
PIT_FREQ = 0x1234DD
TIMER_CTRL = 0x43
TIMER0_CTRL = 0x40
TIMER0 = 0
TIMER_MODE2 = (1 << 1)
TIMER_WHOLE = (1 << 4) + (2 << 4)
There's more options to configure, of course. Any documentation on the PIT should explain them all. http://www.neuraldk.org/cgi-bin/download.pl?ndk contains a working example (timer.c,h)
Cheers,
Jeff