Page 1 of 1

A problem with the keyboard controller

Posted: Sat Apr 23, 2011 4:33 am
by trinopoty
Hi all,
I am writing a function which polls the keyboard and the RTC constantly and executes a certain task. During keyboard polling,
I am checking the Bit 0 at port 0x64 to check whether the keyboard output buffer is full. I have a document which says that
the bit clears when port 0x60 is read to get the scancode, but it is not clearing and causing my loop to stop accepting any
other keystrokes. The timer part is fine and works as expected. Here is the code:

Code: Select all

OutPortB(0x70, 0x00);
unsigned char initial = InPortB(0x71);
unsigned char current;

while(1)
{
	if((InPortB(0x64)&0x01) == 0x01)
	{
		unsigned char scan = KeyboardInt();
	}
	
	//
	OutPortB(0x70, 0x00);
	current = InPortB(0x71);
	if(initial != current)
	{
		initial = current;
		// timer function
	}
}
The KeyboardInit() function reads the scan code, sets the leds and returns the scancode.
I have also tried hooking to int 0x09 but no good.

Re: A problem with the keyboard controller

Posted: Sat Apr 23, 2011 1:07 pm
by bewing
I don't see how "the bit not clearing" would stop your loop from "accepting further scancodes"?

Is this running in real mode, or protected mode? Is it running in an emulator, or on real hardware?

When a user hits a key, this puts both a keydown and a keyup scancode in the buffer. If you are using some other scanset than scanset 1, this can easily be more than 3 bytes. Setting the LEDs also puts an "ACK" scancode in the buffer.

The 0 bit on port 0x64 does not clear until you have read all the bytes from the port 0x60 buffer.

Re: A problem with the keyboard controller

Posted: Wed Jan 04, 2012 9:45 am
by trinopoty
I was running it in vmware. But now, the problem is solved.