Page 1 of 2
[RESOLVED] ps/2 mouse initalization / keyboard interrupt
Posted: Sun Oct 23, 2011 3:58 pm
by megatron23
If I initialize the mouse with
SANiK's code and enable IRQ12 IRQ1 for keyboard input won't fire anymore. What could I have done wrong?
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Sun Oct 23, 2011 4:10 pm
by egos
Show your ISR code for IRQ12.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Sun Oct 23, 2011 4:19 pm
by megatron23
Code: Select all
void mouse_handler() {
uint8 mouse_stat = inportb(0x64);
if ( !(mouse_stat & 0x01) || !(mouse_stat & 0x20) ) {
return;
}
switch(mouse_cycle) {
case 0:
mouse_byte[0]=inportb(0x60);
mouse_cycle++;
break;
case 1:
mouse_byte[1]=inportb(0x60);
mouse_cycle++;
break;
case 2:
mouse_byte[2]=inportb(0x60);
mouse_x=mouse_byte[1];
mouse_y=mouse_byte[2];
mouse_cycle=0;
break;
}
}
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Sun Oct 23, 2011 6:51 pm
by egos
Well
But where's EOI command?
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 3:27 am
by megatron23
egos wrote:Well
But where's EOI command?
That is in my ISR. I replied before you edited your reply from "Post your mouse handler".
The ISR calls the mouse_handler and EOI afterwards.
Other IRQs like 0 or 8 do fire, exept IRQ 1.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 3:37 am
by Bietje
What PIC mask did you set?
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 4:44 am
by megatron23
The pic mask set for IRQ12 is 0xEF on PIC2. Bit nr. 12 in word thus bit nr. 4 in byte for the dataport of pic 2.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 6:08 am
by Combuster
That's only the second half of the answer
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 6:50 am
by megatron23
It seems I missed the plot a little. Then what would be the first half?
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 7:20 am
by egos
I think he means PIC1 mask.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 8:38 am
by megatron23
I dont send a mask to PIC1 if I want to enable IRQ12.
The IRQ1 for keyboard is enabled elsewhere. It works without problems if I don't initialize the mouse.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 9:14 am
by egos
Does mouse work fine? Check program step by step to localise the fragment where keyboard is missed. Read controller command byte again to check that it is correct.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 10:21 am
by megatron23
After enabling interrupts IRQ12 fires once where neither bit 0 nor bit 5 ist set in the byte from port 0x64. my handler then does not read data from port 0x60 and returns instead.
after that everything works as it should except IRQ1 does not fire anymore.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 12:28 pm
by egos
Controller command byte is the byte which you can read by command 20h. This byte contains "enable keyboard/mouse interrupt" bits and "disable keyboard/mouse" bits. Read and show this byte.
Re: ps/2 mouse initalization / keyboard interrupt
Posted: Mon Oct 24, 2011 1:42 pm
by turdus
megatron23 wrote:After enabling interrupts IRQ12 fires once where neither bit 0 nor bit 5 ist set in the byte from port 0x64.
That could take a while to set. Read and check it in a loop (timeout). For example I try it 1000 times before saying it was a false IRQ.