⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interfacing the pc's keyboard.htm

📁 使用68HC705J1A写的一个键盘的代码,包括资料说明,一份难得的资料,本人开发键盘时好不容易才找到的资料
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.beyondlogic.org/keyboard/keybrd.htm -->
<HTML><HEAD><TITLE>Interfacing the PC's Keyboard.</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META 
content="Details the AT Keyboard Interface and AT Keyboard Protocols. Includes an example Keyboard to ASCII decoder using a 68HC705J1A MCU." 
name=description>
<META content="Keyboard, Scan Code, AT, 101 key, HC705J1A, HC11" name=keywords>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY leftMargin=0 background="Interfacing the PC's Keyboard.files/bgyellow.gif" 
topMargin=0 FACE="ARIAL" BASEFONT marginwidth="0" marginheight="0">
<STYLE type=text/css>#TITLEBLOCK {
	COLOR: #ffffff; TEXT-DECORATION: none
}
TD {
	FONT-FAMILY: Arial
}
P {
	FONT-FAMILY: Arial
}
FONT {
	FONT-FAMILY: Arial
}
A {
	FONT-FAMILY: Arial
}
</STYLE>

<SCRIPT language=javascript 
src="Interfacing the PC's Keyboard.files/beyondmenu.js"></SCRIPT>

<CENTER><BR><FONT face=ARIAL color=green size=5><B>Interfacing the AT 
keyboard.</B></FONT> 
<TABLE width="95%">
  <TBODY>
  <TR>
    <TD><FONT face=ARIAL><BR>
      <P>Why would you want to interface the Keyboard? The IBM keyboard can be a 
      cheap alternative to a keyboard on a Microprocessor development system. Or 
      maybe you want a remote terminal, just couple it with a LCD Module. </P>
      <P>Maybe you have a RS-232 Barcode Scanner or other input devices, which 
      you want to use with existing software which only allows you to key in 
      numbers or letters. You could design yourself a little box to convert 
      RS-232 into a Keyboard Transmission, making it transparent to the 
      software. </P>
      <P>An interfacing example is given showing the keyboard's protocols in 
      action. This interfacing example uses a 68HC705J1A MCU to decode an IBM AT 
      keyboard and output the ASCII equivalent of the key pressed at 9600 BPS. 
      </P>
      <P>Note that this page only deals with AT Keyboards. If you have any XT 
      keyboards, you wish to interface, consider placing them in a museum. We 
      will not deal with this type of keyboard in this document. XT Keyboards 
      use a different protocol compared to the AT, thus code contained on this 
      page will be incompatible. </P>
      <UL></UL><BR>
      <HR>
      <B><FONT size=+2>PC Keyboard Theory</FONT></B>
      <HR>
       
      <UL>
        <P>The IBM keyboard you most probably have sitting in front of you, 
        sends scan codes to your computer. The scan codes tell your Keyboard 
        Bios, what keys you have pressed or released. Take for example the 'A' 
        Key. The 'A' key has a scan code of 1C (hex). When you press the 'A' 
        key, your keyboard will send 1C down it's serial line. If you are still 
        holding it down, for longer than it's typematic delay, another 1C will 
        be sent. This keeps occurring until another key has been pressed, or if 
        the 'A' key has been released. </P>
        <P>However your keyboard will also send another code when the key has 
        been released. Take the example of the 'A' key again, when released, the 
        keyboard will send F0 (hex) to tell you that the key with the proceeding 
        scan code has been released. It will then send 1C, so you know which key 
        has been released. </P>
        <P>Your keyboard only has one code for each key. It doesn't care it the 
        shift key has been pressed. It will still send you the same code. It's 
        up to your keyboard BIOS to determine this and take the appropriate 
        action. Your keyboard doesn't even process the Num Lock, Caps Lock and 
        Scroll Lock. When you press the Caps Lock for example, the keyboard will 
        send the scan code for the cap locks. It is then up to your keyboard 
        BIOS to send a code to the keyboard to turn on the Caps lock LED. </P>
        <P>Now there's 101 keys and 8 bits make 256 different combinations, thus 
        you only need to send one byte per key, right? </P>
        <P>Nop. Unfortunately a handful of the keys found on your keyboard are 
        extended keys, and thus require two scan code. These keys are preceded 
        by a E0 (hex). But it doesn't stop at two scan codes either. How about 
        E1,14,77,E1,F0,14,F0,77! Now that can't be a valid scan code? Wrong 
        again. It's happens to be sent when you press the Pause/break key. Don't 
        ask me why they have to make it so long! Maybe they were having a bad 
        day or something? </P>
        <P>When an extended key has been released, it would be expect that F0 
        would be sent to tell you that a key has been released. Then you would 
        expect E0, telling you it was an extended key followed by the scan code 
        for the key pressed. However this is not the case. E0 is sent first, 
        followed by F0, when an extended key has been released. </P><B><FONT 
        size=+2>Keyboard Commands</FONT></B>
        <HR>
         
        <P>Besides Scan codes, commands can also be sent to and from the 
        keyboard. The following section details the function of these commands. 
        By no means is this a complete list. These are only some of the more 
        common commands. </P>
        <UL><B><FONT size=+2>Host Commands</FONT></B>
          <HR>
           
          <P>These commands are sent by the Host to the Keyboard. The most 
          common command would be the setting/resetting of the Status Indicators 
          (i.e. the Num lock, Caps Lock &amp; Scroll Lock LEDs). The more common 
          and useful commands are shown below. 
          <P>
          <CENTER>
          <TABLE width="80%" border=0>
            <TBODY>
            <TR>
              <TD vAlign=top><B>ED</B></TD>
              <TD><B>Set Status LED's - This command can be used to turn on 
                and off the Num Lock, Caps Lock &amp; Scroll Lock LED's. After 
                Sending ED, keyboard will reply with ACK (FA) and wait for 
                another byte which determines their Status. Bit 0 controls the 
                Scroll Lock, Bit 1 the Num Lock and Bit 2 the Caps lock. Bits 3 
                to 7 are ignored. </B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>EE</TD>
              <TD>Echo - Upon sending a Echo command to the Keyboard, the 
                keyboard should reply with a Echo (EE)</TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top><B>F0</B></TD>
              <TD><B>Set Scan Code Set. Upon Sending F0, keyboard will reply 
                with ACK (FA) and wait for another byte, 01-03 which determines 
                the Scan Code Used. Sending 00 as the second byte will return 
                the Scan Code Set currently in Use </B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>F3</TD>
              <TD>Set Typematic Repeat Rate. Keyboard will Acknowledge command 
                with FA and wait for second byte, which determines the Typematic 
                Repeat Rate.</TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top><B>F4</B></TD>
              <TD><B>Keyboard Enable - Clears the keyboards output buffer, 
                enables Keyboard Scanning and returns an 
            Acknowledgment.</B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>F5</TD>
              <TD>Keyboard Disable - Resets the keyboard, disables Keyboard 
                Scanning and returns an Acknowledgment.</TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top><B>FE</B></TD>
              <TD><B>Resend - Upon receipt of the resend command the keyboard 
                will re- transmit the last byte sent.</B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>FF</TD>
              <TD>Reset - Resets the 
          Keyboard.</TD></TR></TBODY></TABLE></CENTER><BR><BR><B><FONT 
          size=+2>Commands</FONT></B>
          <HR>
           
          <P>Now if the Host Commands are send from the host to the keyboard, 
          then the keyboard commands must be sent from the keyboard to host. If 
          you think this way, you must be correct. Below details some of the 
          commands which the keyboard can send. </P><BR>
          <CENTER>
          <TABLE width="80%" border=0>
            <TBODY>
            <TR>
              <TD vAlign=top><B>FA</B></TD>
              <TD><B>Acknowledge</B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>AA</TD>
              <TD>Power On Self Test Passed (BAT Completed)</TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top><B>EE</B></TD>
              <TD><B>See Echo Command (Host Commands)</B></TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>
            <TR>
              <TD vAlign=top>FE</TD>
              <TD>Resend - Upon receipt of the resend command the Host should 
                re-transmit the last byte sent. </TD></TR>
            <TR>
              <TD></TD>
              <TD></TD></TR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -