Page 2 of 2

Re: I'm not getting any IRQ's from my PIC

Posted: Tue Jun 11, 2013 11:54 pm
by Brendan
Hi,
Gogeta70 wrote:Ok, so i have things working a lot better now. But, i'm only receiving my keyboard interrupt once. I receive a system timer interrupt (IRQ0) constantly though :/
I haven't programmed the PIT. Should i be getting any IRQ0's?
The BIOS sets the PIT up for 18.2 Hz. If you don't touch the PIT, then the PIT will be left in the state the BIOS left it in; and you'll get an IRQ from the PIT every 55 ms.
Combuster wrote:Also, you are not reading the keyboard buffer yet either so it might just fill up and go dead as well.
It will go dead. The PS/2 controller has a 1-byte buffer. When a byte (from the keyboard) goes into that buffer the PS/2 controller generates an interrupt; and if the byte isn't read by software the buffer remains full, which prevents another byte (from the keyboard) from going into the "already full" buffer, which prevents a second IRQ.
Gogeta70 wrote:I know some of the standard interrupts (numbers 0x00 - 0x1f) have error codes, but do any of the interrupts generated by the PIC have an error code associated with them?
Those interrupts (numbers 0x00 - 0x1F) are exceptions. Exceptions are the only types of interrupts that have error codes.
Gogeta70 wrote:Here are my pic_eoi functions:
The slave PIC is connected to the "input #2" of the master PIC. This means that when a device connected to the slave PIC generates an IRQ, the slave PIC tells the master PIC and the master PIC tells the CPU. This also means when a device connected to the slave PIC generates an IRQ, you have to send the EOI to both the master PIC and the slave PIC, like this:

Code: Select all

global pic2_eoi
pic2_eoi:
	
	mov	al, 0x20	; set bit 4 of OCW 2
	out	0x20, al	; write to primary PIC command register
	out	0xA0, al	; write to secondary PIC command register
	ret
Also note that PIC chips can send "spurious IRQs" and you should not send an EOI to a PIC chip that has sent a spurious IRQ. For IRQ 7 you have to ask the master PIC chip if the IRQ is a real IRQ 7 or if it's a spurious IRQ that should be ignored; and if it is a spurious IRQ you just do IRET without sending any EOI. For IRQ 15 you have to ask the slave PIC chip if the IRQ is a real IRQ 15 or if it's a spurious IRQ; and if it is a spurious IRQ that should be ignored you do need to send an EOI to the master PIC but shouldn't send an EOI to the slave PIC.


Cheers,

Brendan

Re: I'm not getting any IRQ's from my PIC

Posted: Wed Jun 12, 2013 3:21 pm
by Gogeta70
I finally got my keyboard driver working!

Thanks for the reminder about spurious IRQ's, i forgot to compensate for them. So the PIT is generating interrupts. Well that clears up that mystery. ^_^

Thanks to everyone for your help!

Image