Page 1 of 3

IRQ0

Posted: Sat Jul 31, 2004 5:23 am
by Jess
What is IRQ0 for, I know it?s the system timer, but when does it fire and what can I use it for? Does it fire every CPU cycle?

Re:IRQ0

Posted: Sat Jul 31, 2004 5:47 am
by Legend
It does not fire every CPU cycle.
It fires always after a specific amount of microseconds. To control this you need to program the PIT (Programmable Interval Timer afaik). Most use IRQ0 for doing scheduling + task switching.

Re:IRQ0

Posted: Sat Jul 31, 2004 6:08 am
by Jess
I see.. I just wanted to make a simple delay function.. should I use this IRQ then? You know any place where I can find info about the PIT?

Re:IRQ0

Posted: Sat Jul 31, 2004 6:44 am
by Jess
and by the way, whats the differenses between IRQ0 and IRQ8?

Re:IRQ0

Posted: Sat Jul 31, 2004 8:21 am
by Brendan
Hi,
Jess wrote: I see.. I just wanted to make a simple delay function.. should I use this IRQ then? You know any place where I can find info about the PIT?

and by the way, whats the differenses between IRQ0 and IRQ8?
You can find information on PIT/IRQ0 and RTC/IRQ8 here:
http://www.cin.ufpe.br/~if118/projeto/PCtim003.txt

IRQ0 is the PIT (Programmable Interval Timer) chip which is capable of generating IRQs at a fixed frequency (oscillator), or after a preset time delay (one shot). It also controls the PC speaker.

IRQ8 is the RTC (Real Time Clock), which can generate a periodic interrupt capable of generating IRQs at a fixed frequency (same as PIT/IRQ0 only different). The RTC also keeps track of real time (second, minute, hour, day, month, year). It also has an update interrupt (which generates an IRQ every second, which is independant to the periodic interrupt). There's also an alarm, which can be set to generate an IRQ at a specific time on a specific day in a specific month in a specific year. This alarm also allows you to set things to "don't care", which can be used to generate an IRQ every hour, every day, once a month, once a year, etc.


Cheers,

Brendan

Re:IRQ0

Posted: Sat Jul 31, 2004 8:44 am
by Jess
thank you

I also found this document, http://www.nondot.org/sabre/os/files/MiscHW/PIT.txt
about the PIT, but it claims that IRQ 8 will fire? But I thought IRQ0 was bonded to the PIT and that IRQ8 was binded to the RTC? A little bit confusing... All I want is to make a function that will wait for some time(milliseconds).

Re:IRQ0

Posted: Sat Jul 31, 2004 8:47 am
by Jess
Or no, it claims that Interrupt 8 will fire. But what is interrupt 8? I?ve remapped the PIC so that IRQ0 will generate Interrupt 0x20.

Re:IRQ0

Posted: Sat Jul 31, 2004 9:09 am
by Jess
Gotta register :)
Forget about the last question, didnt use my head enought..

anyways, I?ve written an ISR for the IRQ0 and it?s running nice and smoothly, but how often does the IRQ0 fires? And how do I change it? Suppose it doesnt require much code

Re:IRQ0

Posted: Sat Jul 31, 2004 9:09 am
by Adek336
Well, interrupt 8 is IRQ0 under DOS. Under your os it will be int 0x20.
How's progress? Remember to EOI. (outb(0x20,0x20))

Re:IRQ0

Posted: Sat Jul 31, 2004 9:14 am
by Jess
Yes, the ISR works and fires, I just wanna controll how many times / second it fires. So I can have something like

void delay(int ms) {
variabel = 0;
unmask_irq(system_timer);
while(variabel < millis)
;
}

void system_timer_irq() {
variabel++;
}

Re:IRQ0

Posted: Sat Jul 31, 2004 9:37 am
by Brendan
Hi,
Jess wrote: Or no, it claims that Interrupt 8 will fire. But what is interrupt 8? I?ve remapped the PIC so that IRQ0 will generate Interrupt 0x20.
This just means that "PIT.txt" (wrongly) assumes that BIOS default PIC settings are in use.


Cheers,

Brendan

Re:IRQ0

Posted: Sat Jul 31, 2004 12:58 pm
by Neo
If you search this board you will find some (many actually) threads where this has been asked and explained in detail (with example code available IIRC)

Re:IRQ0

Posted: Sun Aug 01, 2004 12:24 am
by Dreamsmith
Jess wrote:and by the way, whats the differenses between IRQ0 and IRQ8?
IRQ 0 is the PIT, whereas IRQ 8 is the RTC. The PIT is a wonderfully versatile chip that can be set to perform a number of tasks, including generating periodic interrupts. The RTC can generate periodic interrupts as well, but only certain frequencies. An advantage of the RTC is that it always generates a particular number of interrupts per second, whereas the PIT is hard to program to generate an exact integer number of interrupts per second. Also, because the RTC lacks the flexibility of the PIT, it actually makes a better source for interrupts for use in task switching and the like. The PIT can do things the RTC can't, so it's a waste to tie it up doing anything the RTC can do just as well. For anything that either chip could do, use the RTC, that way, the PIT will still be available for doing the things only the PIT can do (like one-shots, odd frequencies, and the like).

Re:IRQ0

Posted: Sun Aug 01, 2004 5:37 am
by Jess
Well, I just want to make a simple delay function for my kernel.. should I use the Real time clock or the PIT for that (any opinions?)

Re:IRQ0

Posted: Sun Aug 01, 2004 5:47 am
by Brendan
Hi,
Jess wrote: Well, I just want to make a simple delay function for my kernel.. should I use the Real time clock or the PIT for that (any opinions?)
Use which-ever one you feel like (it probably wouldn't matter much).

If you want something really simple you could use the PIT and leave it set to it's default fequency (18.2065 Hz, or once every 54.9254 milliseconds). In this case all you'd need to do is install an IRQ handler and enable it in the PIC.


Cheers,

Brendan