Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/21/02 06:20
Read: times


 
#32853 - RE: Write the command to Keyboard
Hi Frank.

I have accomplished communicating with PC keyboard, recently.

To inhibit communication, I took KBD Clock line low for 100 usec, then KBD Data line low and then KBD Clock line high.

I am pasting the code below...

--------------------------------------------
// ***** START TIMER0 FOR 100USEC *****
ET0 = 0; // Disable timer 0 interrupt
TR0 = 0; // Stop timer 0
TF0 = 0; // Clear overflow flag
TH0 = RELOAD_HIGH_VALUE_100USEC;
TL0 = RELOAD_LOW_VALUE_100USEC; // load
TR0 = 1; //Start timer0
// ***** START TIMER0 FOR 100USEC *****

KEYBOARD_CLOCK_PORT = 0;// inhibit comm

while (1 != TF0) // Wait for overflow
{
}

KEYBOARD_DATA_PORT = 0; // Apply "Request-to-send" by pulling Data low, then release Clock ("START-bit")

KEYBOARD_CLOCK_PORT = 1; // Release the clock

KEYBOARD_INTERRUPT_PENDING_FLAG = 0; // Clear interrupt flag which was set due to "pull-low" of "Clock"

--------------------------------------------

I have used INT0 pin of 89C51 for clock.

Remember, that when sending commands to the keyboard, data can change only when the clock line is low, as keyboard reads it on the rising edge of the clock.

Now, if you look closely at the first time you play with the clock and data line, it is like sending the START BIT to the keyboard.
Since data can change only while clock is low, and on rising edge, the keyboard reads it, you do it for the keyboard the first time. After that it starts genarating the clock.

Regards
Aman


List of 5 messages in thread
TopicAuthorDate
Write the command to Keyboard            01/01/70 00:00      
RE: Write the command to Keyboard            01/01/70 00:00      
RE: Write the command to Keyboard            01/01/70 00:00      
RE: Write the command to Keyboard            01/01/70 00:00      
RE: Write the command to Keyboard            01/01/70 00:00      

Back to Subject List