A problem with the keyboard controller

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

A problem with the keyboard controller

Post 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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: A problem with the keyboard controller

Post 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.
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

Re: A problem with the keyboard controller

Post by trinopoty »

I was running it in vmware. But now, the problem is solved.
Post Reply