Professional Documents
Culture Documents
Z8602/14/15/C15/E23 MICROCONTROLLERS
CONTROL A 101/102 PC/KEYBOARD
S can codes, line status modes, key bounce, make/break status, scan timing...
the Microcontroller does all this and much more.
INTRODUCTION
Zilog has continuously provided cost-effective solutions for the 101/102 keyboard environment; the Z8614,
for the keyboard controller market. Design time to compared to the Z8602, provides additional ROM space
production is dramatically shortened by Zilog's easy-to- for an expanded feature set; and the Z8615/C15 provides
use development tools, source code availability, and steady integration of external componentry.
relationships with major manufacturers that assist in defining
the product line feature set. These microcontrollers are designed into a PC keyboard to
control all scan codes, line status modes, scan timing, and
Zilog provides the following microcontrollers dedicated to communications between the keyboard and PC. This
keyboard operation: Z8602, Z8614, Z8615, Z86C15, and application note depicts a typical method of interfacing a
the Z86E23. The Z86E23 provides prototyping capability standard keyboard to an PC XT/AT.
KEYBOARD OVERVIEW
The 101/102 PC/Keyboard includes the following: 101/102 provides a 5V power supply, common ground, and bi-
keypads, Zilog microcontroller, 3 LED indicators (for Num, directional Data and Clock lines for serial data
Caps, and Scroll) for lock status, selection switch for communications (see Figure 1).
PC/XT, and a cable between PC and keyboard. The cable
1 3
4 5
2
AP95KEY0200 1
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
2 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
(1) Main Program Loop (2) Keyboard Scan and Make/Break (3) Communication Between
Code Generation PC and Keyboard
(executed every 4.17 millisecond) (executed every 250 microsecond)
Return
Case Status Detection
Transmit Data/Ack
Break_Code Generation
no no End of
6 Keys Tested? Communication?
yes yes
no Execute each command
Typematic Case?
yes
Delay & Rate Counting Return
no
Time to Generate? Receive Data/Command
yes
no
Return Option data? yes
no
Send RESEND command
Return
Receive Command/Data
Return
AP95KEY0200 3
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
4 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
The keyboard contains 101/102 keypads. All keypads are The key detection loop continues (loop from bounce=5,
scanned every 4.17 ms by the keyboard controller. The bounce=7, bounce=6) until two key release detections
microcontroller handles a maximum of six keys concurrently (from bounce=6 to bounce=5). The bounce bit is set to four
by means of the key bounce process and case conditions. (bounce=4) when the key release is detected two times.
(If more than six keys are pressed concurrently, they are The number is stored until generation of the Break scan
ignored.) Quick multiple key passing for the first six keys code, then it is reset to zero in the Make/Break module. The
generate the scan codes. first six keys generate the Make scan code and Break scan
code when multiple keys are pressed. Concurrently, the
The key scanning is done from column output 15 toward rest of the keys are ignored. (Refer to Figure 6, which
column output 0 by keeping one of the column outputs at illustrates the Make and Break scan code process.
a low level and the remaining outputs at a high level.
Whenever a low level output sets on one of the column
ports, eight row inputs are tested 20 µs later. The timing
chart of keyboard scanning is illustrated in Figure 3.
AP95KEY0200 5
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
22 µF 0.1 µF
1
VCC 21 COL0
P10
P11 22 COL1
3 23 COL2
XTAL1 P12
2-4 MHz
2 P13 24 COL3
XTAL2
P14 25 COL4
100 pF
P15 26 COL5
P16 27 COL6
47K
P17 28 COL7
6
/RESET
P00 13 COL8
1 µF P01 14 COL9
P02 15 COL10
Scroll Lock 330 Ω
29 P03 16 COL11
P34
P04 17 COL12
Num Lock 330 Ω 18 COL13
10 P05
P35
P06 19 COL14
Caps Lock 330 Ω
40 P07 20 COL15
+5V P36
82K x 8
+5V P30 5 ROW0
2.2K
P31 39 ROW1
CLOCK 32
P21 P32 33 ROW2
P33 30 ROW3
DATA 31
P20 P24 35 ROW4
GND 2.2K
36 ROW5
NC ROMLESS P25
37 ROW6
P26
34 38 ROW7
P23 P27
VSS
82K
Close = PC/XT mode 11
Open = PC/AT mode +5V
6 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
0.1 µF 1%
Precision
Resistor
1
3 VCC
P10 21 COL0
XTAL 1
P11 22 COL1
2 P12 23 COL2
XTAL 2
P13 24 COL3
P14 25 COL4 101/102-key
9
/WDTOUT P15 26 COL5
Keyboard
P16 27 COL6
6 /RESET P17 28 COL7
P20 31 COL8
Scroll Lock 29 Z8615
P34 P21 32 COL9
Num Lock 10 P22 33 COL10
P35
P23 34 COL11
Caps Lock 40 P04 17 COL12
P36
P05 18 COL13
+5V P06 19 COL14
P07 20 COL15
CLOCK 37
P26
P00 13 ROW0
DATA 38 P01 14 ROW1
P27
P02 15 ROW2
GND
P03 15 ROW3
P30 5 ROW4
35 P31 39 ROW5
P24
P32 12 ROW6
P33 30 ROW7
Close = PC/XT mode VSS
Open = PC AT mode
11
AP95KEY0200 7
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
8 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
AP95KEY0200 9
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
ROW7 50 51 61 55 84 89 105 79 62
ROW0
110 45 115 35 36 116 117 41 99 104 83 60
ROW1
44 16 30 114 21 22 15 118 28 27 92 97 102
ROW2
58 1 112 113 6 7 120 119 13 12 76 75 85 80
ROW4
17 18 19 20 23 25 24 26 91 96 101 106 125
ROW5
31 32 33 34 37 29 39 38 40 93 98 103 108
ROW6
64 57 46 47 48 49 52 43 54 53 42 90 95 100 126
COL0 COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14 COL15
10 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
No key detection
bounce = 0
bounce = 1
Data is sent to PC
bounce = 6
Key detected
Decremented
at break detection
No key
detection
bounce = 7
Key detected
bounce = 5
No key detected
Data is sent to PC
AP95KEY0200 11
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
+ XORed
12 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
The Key Matrix Table has the index address offset of the
Scan Code Table. The Scan Code Set Table contains all Rate bits
Make Code keys. The Scan Code Table Map organization Delay bits
is shown in Table 2 and Figure 10. 0
Typematic Attribute
The Scan Code Set 3 is similar to Scan Code Set 2. It is the TYPEMATIC
scan_code set flag (1=Scan Code 1, 2 = Scan Code Set D7 D6 D5 D4 D3 D2 D1 D0
2, and 3 = Scan Code Set 3), which specifies the Scan
Code Table to use. If the scan_code_ set flag is 3 (Scan Pointer for KEY_DATA
Code Set 3), its data checks for typematic *attributes. The
typematic attribute for scan codes (addresses 7-83H) store
KEY_TYPE
in the scratch pad RAM. The four typematic attributes
include; Typematic, Make/Break, Make and Typematic/ D7 D6 D5 D4 D3 D2 D1 D0
AP95KEY0200 AN008701-0301 13
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
NORMAL CASE
SET1 SET 2 AND 3
65
SET 3 SET 2
89
KEY #62, 64, 108
92
KEY #95
93
KEY #75-89
103
KEY #124
104
KEY #126
14 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
no
Bounce = 3?
yes
no
Delay Time Setting Bounce = 4?
yes
no
6 Keys tested?
yes
no
Typematic Key?
yes
no
Time to Generate?
yes
end
AP95KEY0200 15
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
Figure 12 and Table 3 show the pin assignment and pin Once the Clock line releases high (active level), the
descriptions, respectively. Figure 13 shows the keyboard has to check the Data line. When the Data line is
communications format between the PC and the keyboard. inactive, the PC requests to send the serial data to the
keyboard. The keyboard has to send serial Clock streams
Communication Between the PC and to receive the data packet from the PC. When both data
Keyboard and Clock lines are active, the keyboard sends the scan
codes to the PC at any time.
Before the keyboard microcontroller drives the keyboard
Clock and Data lines, it sets both lines to a high level to Serial Data Stream
check the current line status. The three line status modes The serial data bit stream consists of 11 bits, which include
between the PC and the keyboard are the following: a start bit, 8 data bits, odd parity bit, and a stop bit. When
bit stream sends data to the PC, all the data bits are
■ Two-way communication between Keyboard and PC guaranteed while the Clock line is low. The data changes
if both Clock and Data lines are high during a high level of the Clock line. When the bit stream
arrives from the PC, the data fetches at the leading edge
■ PC sends to Keyboard if Data line is low of the Clock. After the stop bit detects high, the KBC forces
the Data line to a low level for one bit period. The start bit
■ PC inhibits communication if Clock is low is always low and the stop bit is high. The 8-bit data
transmits from the least significant bit (LSB). The odd parity
bit means that the number of 1s for the data bit and the
parity bit must be odd all the time.
16 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
+5V 1 40 P36
XTAL2 2 39 P31
XTAL1 3 38 P27
P37 4 37 P26
P30 5 36 P25
Z8602/14/15/
/RESET 6 15C/E23 35 P24
N/C 7 * ** 34 P23
N/C 8 * 33 P22
N/C 9 ** 32 P21
P35 10 31 P20
GND 11 30 P33
P32 12 29 P34
P00 13 28 P17
P01 14 27 P16
P02 15 26 P15
P03 16 25 P14
P04 17 24 P13
P05 18 23 P12
P06 19 22 P11
P07 20 21 P10
AP95KEY0200 17
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
Notes:
IN = Input Port
PUR = Pull-up Resistor
OUT = Output Port
OD = Open-Drain Output
N/C = No Connection
* For the Z8615/C15 only: Pin7 = AGnd; Pin 9 = WDT Output.
18 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
AP95KEY0200 19
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
Notes:
ACK = Acknowledge Data to PC (0FAh)
XX = Received Data from PC.
YY = Result of Basic Assurance Test
AB 83 = ID Number
20 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
CURRENT_BUFFER0 = 0Eh
oooooooooooooo oooooooooooooo
AP95KEY0200 21
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
Whenever Data line goes low (from PC), the microcontroller Table 5 shows working registers specifying the initial
receives the data by driving the Clock line eleven times. values used to handle serial data transfers.
The received data is always checked whether or not it is a
new command. The command compares to the Command Table 5. Serial Data Transfer Working Registers
data defined in com_gen macro.
Register Function
If it is a new command, then it is stored in a COMMAND Serial Data Output
register. The first parameter of com_gen saves to the CF (carry flag) 0 to set low start bit
COM_STATUS register. The COM_STATUS shows how serial data hi bit7-1=1 and bit0 = odd parity bit
many bytes are handled in the current command. The serial data lo 8 bits data to be transmitted
acknowledge data (0FAh) sets to COMMAND_BUFFER bit count 11 = number of bit transmitted
and departs in the next Timer0 interrupt. serial bit temporary register for P2 I/O port
transmit 0ffh to specify transmit mode
After that transmission, COM_STATUS decrements by one com_delay to set up 80 µsec/bit timing
and tests for zero. If it is zero, the communication is over P2 P2.1 = Clock to make pulse,
and the program executes by getting a jump address from P2.0=Data to transmit data
the com_gen macro table.
Serial Data Input
If it is not zero, the communication remains active. The new CF (carry flag) 1 to set low high output for input mode
command buffer sets to 0 unless the current command is serial data hi 0ffh to receive 8 bits data
READ_ID. The command buffer at 0 means data receive; serial data lo 0ffh to receive 3 bits data
non-zero means a data transmission to the PC. After the bit_count 11 = number of bits received
proper data transfer, the acknowledge data is sent. Now, serial bit temporary register for P2 I/O port
each command is executable. transmit 0 to specify receive mode
com_delay to set up 80 µsec/bit timing
P2 P2.1 = Clock to make pulse,
P2.0=Data to receive
22 AP95KEY0200
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
COM_STATUS=2
Data Receive from IBM PC
Data Transmission to IBM PC
AP95KEY0200 23
AN008701-0301
Z8602/14/15/C15/E23 KEYBOARD MICROCONTROLLERS
ZILOG CONTROL A 101/102 PC/KEYBOARD – APPLICATION NOTE
The period of one data bit is 80 µs; the data must change
when the Clock pulse is high. In fact, the switching is done
20 µs after the leading edge of the Clock pulse.
Transmit Mode
In the second mode, line contention is always detected by
the Clock line during a high level. If the Clock line goes low,
the PC drives the line. If line contention appears before the
10th bit transmission, the system immediately quits the
process and sets both Data and Clock lines to high. If
detection occurs after the 10th bit, sending continues until
complete.
Receive Mode
In the Receive mode, the 10th bit tests for high. If high, the
PC sends a low level for the 11th bit period to show an
acknowledge. This means successful data reception from
the PC. Otherwise, the PC sends multiple Clock pulses
until it receives the correct stop bit.
© 1997 by Zilog, Inc. All rights reserved. No part of this document Zilog’s products are not authorized for use as critical compo-
may be copied or reproduced in any form or by any means nents in life support devices or systems unless a specific written
without the prior written consent of Zilog, Inc. The information in agreement pertaining to such intended use is executed between
this document is subject to change without notice. Devices sold the customer and Zilog prior to use. Life support devices or
by Zilog, Inc. are covered by warranty and patent indemnification systems are those which are intended for surgical implantation
provisions appearing in Zilog, Inc. Terms and Conditions of Sale into the body, or which sustains life whose failure to perform,
only. when properly used in accordance with instructions for use
provided in the labeling, can be reasonably expected to result in
ZILOG, INC. MAKES NO WARRANTY, EXPRESS, STATUTORY, significant injury to the user.
IMPLIED OR BY DESCRIPTION, REGARDING THE INFORMA-
TION SET FORTH HEREIN OR REGARDING THE FREEDOM OF Zilog, Inc. 210 East Hacienda Ave.
THE DESCRIBED DEVICES FROM INTELLECTUAL PROPERTY Campbell, CA 95008-6600
INFRINGEMENT. ZILOG, INC. MAKES NO WARRANTY OF MER- Telephone (408) 370-8000
CHANTABILITY OR FITNESS FOR ANY PURPOSE. Telex 910-338-7621
FAX 408 370-8056
Zilog, Inc. shall not be responsible for any errors that may appear Internet: http://www.zilog.com
in this document. Zilog, Inc. makes no commitment to update or
keep current the information contained in this document.
24 AP95KEY0200
AN008701-0301