AN434 Connecting a PC keyboard to the I2C-bus

Aug 26, 1992 - response, the 8XC751 interrupt service routine samples .... accumulator bits. 0058+ 0000 .... 0181 00B5 ; keyboard interrupt service routine ;.
81KB taille 1 téléchargements 283 vues
Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

CONNECTING A PC KEYBOARD TO THE I2C BUS

Keyboard-to-I2C Hardware (Figure 4)

This application note illustrates the use of a low-cost 8-bit microcontroller—the 8XC751—to interface a standard PC/AT keyboard to the I2C bus. The 8XC751 (83C751 = ROM-version, 87C571 = EPROM-version) is ideally suited for the task thanks to its built-in I2C interface, small form-factor (24-pin DIP or 28-pin PLCC) and low power consumption (11mA typical @12 MHz; see Figure 1). The application software easily fits within the 2K bytes code and 64 bytes data memory provided on the 8XC751.

The 8XC751 on-chip I2C interface allows direct connection of the SDA (Serial Data) and SCL (Serial Clock) pins to the corresponding I2C bus lines. Since the I2C bus is open collector (allowing multimasters), 10K resistors are used to pull the lines to the idle state between keypresses.

The PC/AT Keyboard

The PC/AT keyboard interface is equally simple. The CLK output from the keyboard is used to generate an interrupt (INT0). In response, the 8XC751 interrupt service routine samples the keyboard serial DATA connected to port 0 bit 2 (P0.2).

The PC/AT keyboard transmits data in a clocked serial format consisting of a start bit, 8 data bits (LSB first), an odd parity bit and a stop bit as shown in Figure 2. Besides clock and data, the 5-pin connector (Figure 3) also includes power, ground and a no connect. Note that the PS/2 keyboard interface is logically equivalent, though it uses a different connector. (A sixth pin provides an additional no connect).

When used with a PC, the keyboard implements a bidirectional communication protocol by exploiting the fact that both the keyboard and PC can drive the open collector CLK and DATA lines. However, bidirectional communication is not required for basic keyboard operation and in this application, the keyboard is treated as an ‘input-only’ device.

When a key is pressed, the PC/AT keyboard transmits a ‘make’ code and, when the key is released, a ‘break’ code. The make code consists of an 8-bit ‘scan’ code denoting the key pressed. The ‘break’ code (key released) consists of the same 8-bit scan code preceded by a special code—0F0H.

The keyboard-to-I2C software performs three major functions:

A notable difference from a regular ASCII keyboard is the way SHIFT, CTRL, ALT, etc. control keys work. For an ASCII keyboard, the control keys directly modify the code output. For example, a 61H (ASCII code for ‘a’) is output if the ‘A’ key is pressed by itself, while a 41H (ASCII code for ‘A’) is output if the SHIFT and ‘A’ keys are pressed simultaneously.

• Send the ASCII code as an I2C message.

The PC/AT keyboard handles such a key combination as two separate key presses, i.e., SHIFT-MAKE, ‘A’-MAKE, SHIFT-BREAK, ‘A’-BREAK. The ‘A’ scan code (1CH) is the same for both the shifted and unshifted state. To determine whether the ‘A’ scan code is interpreted as ‘A’ or ‘a’ the PC must keep track of the presence or absence of a prior SHIFT-MAKE.

August 26, 1992

AN434

example, a keyboard SHIFT-MAKE, ‘A’-MAKE, SHIFT-BREAK, ‘A’-BREAK sequence is converted to the ASCII code for uppercase ‘A’ (41H). The flowchart in Figure 5 depicts the keyboard data capture and code conversion process. The 8XC751 operates as an I2C slave. When the master issues a read command, the 8XC751 returns the converted ASCII character. The seven least significant bits are used for the ASCII code, while the most significant bit is used as a NEW flag (0 = new, 1 = old). The key code remains marked as new until the master issues a write to the 8XC751 at which point it is marked as old and will be overwritten by the next key processed. The keyboard-to-I2C software is shown immediately following Figure 5. Less than half the code space available on the 8XC751 is used, leaving room for extra features such as parity checking and more complete keyboard control state mapping using additional look-up tables.

Keyboard-to-I2C Software

• Capture the clocked serial data from the keyboard

• Translate the keyboard data to the corresponding ASCII code

When a key is pressed, the CLK output from the keyboard generates an interrupt via INT0. The 8XC751 shifts in the DATA from the keyboard on P0.2 (port 0, bit 2) and extracts the 8-bit scan code from the 11-bit packet. Next, the scan code is interpreted and converted to the corresponding ASCII code using a look-up table. Keyboard multi-code outputs are converted to single ASCII codes by tracking the state (i.e. shifted vs. unshifted) of the keyboard and using separate look-up tables for each. For

1

P3.4/A4 1

24 V CC

P3.3/A3 2

23 P3.5/A5

P3.2/A2/A10 3

22 P3.6/A6

P3.1/A1/A9 4

21 P3.7/A7

P3.0/A0/A8 5

20 P1.7/T0/D7

P0.2/VPP 6 P0.1/SDA/ 7 OE–PGM P0.0/SCL/ 8 ASEL RST

9

DIP

19 P1.6/INT1/D6 18 P1.5/INT0/D5 17 P1.4/D4 16 P1.3/D3

X2 10

15 P1.2/D2

X1 11

14 P1.1/D1

12

13 P1.0/D0

VSS

Figure 1. Pin Configuration

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

DATA

start

D0

D1

D2

D3

AN434

D4

D5

D6

D7

parity

stop

CLK

20µs typ. 80µs typ. Figure 2. PC/AT Keyboard Timing

1

RESET

5

CLOCK

4

2 3

5 VOLTS

GND

DATA

Figure 3. Keyboard Connections (looking into the connector)

VCC = 5V

KEYBOARD CONNECTOR

1

5 2

N/C

3

CLK 1

4

2 10K

10K

10K 3 4

DATA GND

5 6 7 8 1µF

SDA SCL

33pF

9 11.06MHz

10 11

33pF

PWR

GND

GND

12

GND

Figure 4. IBM Keyboard to I2C Bus Format Using the 8XC751

August 26, 1992

2

N/C

VCC

N/C

N/C

N/C

N/C

N/C

N/C

N/C P0.2 SDA SCL RST

8 7 C 7 5 1

N/C N/C INT0 N/C N/C

X1

N/C

X2

N/C

VSS

N/C

24 23 22 21 20 19 18 17 16 15 14 13

10K

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

AN434

Save registers

BIT# = 0 ?

Bit#=1 to 8 ?

Bit#=9 ?

KEY=SHIFT ?

Shift keyboard DATA line (P0.2) into variable KEY.

Parity check (optional)

LASTKEY = BREAK code ?

Set SHIFT flag

Clear SHIFT flag

KEY=CTRL ?

KEY=BREAK code ?

CTRL key handling (optional)

LASTKEY=BREAK code

LASTKEY = BREAK code ?

LASTKEY=KEY

SHIFT flag set ?

Translate to ASCII using ‘shifted’ look-up table

Translate to ASCII using ‘unshifted look-up table

BIT#=BIT#+1

BIT#=0

Restore Registers

Figure 5. Keyboard Data Capture and Conversion August 26, 1992

3

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0001+ 0002+ 0003+ 0004+ 0005+ 0006+ 0007+ 0008+ 0009+ 0010+ 0011+ 0012+ 0013+ 0014+ 0015+ 0016+ 0017+ 0018+ 0019+ 0020+ 0021+ 0022+ 0023+ 0024+ 0025+ 0026+ 0027+ 0028+ 0029+ 0030+ 0031+ 0032+ 0033+ 0034+ 0035+ 0036+ 0037+ 0038+ 0039+ 0040+ 0041+ 0042+ 0043+ 0044+ 0045+ 0046+ 0047+

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

August 26, 1992

;******************************** ; ; ; Copyright Micro AMPS Ltd ; ; & Philips Semiconductors ; ; Dec 1990 ; ; ; ;******************************** ; Read data under interrupt from an IBM keyboard ; Hardware resources: ; Kbd clock on interrupt INT0 P1.5 ; Kbd data on pin P0.2

; This program reads keys in from the keyboard ; and translates them to ASCII

#include equates.51 ; direct addresses for the standard 8051 processor p0 sp dpl dph

.equ .equ .equ .equ

80h 81h 82h 83h

; ; ; ;

port 0 stack pointer data pointer low data pointer high

pcon tcon tmod tl0 th0

.equ .equ .equ .equ .equ

87h 88h 89h 8ah 8ch

; ; ; ; ;

power timer timer timer timer

th1

.equ 8dh

; timer 1 high

p1 scon s0con s0buf

.equ .equ .equ .equ

90h 98h 98h 99h

; ; ; ;

p2 p3 ien0 ie

.equ .equ .equ .equ

0a0h 0b0h 0a8h 0a8h

; port 2 ; port 3 ; interrupt enable

psw acc b

.equ 0d0h .equ 0e0h .equ 0f0h

control control mode 0 low 0 high

port 1 serial control serial control serial data

; program status word ; accumulator ; b register

; bit addressed flags it0 ie0 it1 ie1 tr0 tf0 tr1 tf1

.equ .equ .equ .equ .equ .equ .equ .equ

88h 89h 8ah 8bh 8ch 8dh 8eh 8fh

; ; ; ; ; ; ; ;

int 0 int 0 int 1 int 1 timer timer timer timer

ri ti

.equ 98h .equ 99h

ien0.7

.equ 0afh

; global int enable/disable

p0.0

.equ 080h

; port 0 bit 0

4

edge/level trigger edge detect edge/level trigger edge detect 0 enable/disable 0 overflow detect 1 enable/disable 1 overflow detect

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0048+ 0049+ 0050+ 0051+ 0052+ 0053+ 0054+ 0055+ 0056+ 0057+ 0058+ 0059+ 0060+ 0061+ 0062+ 0063+ 0064+ 0065+ 0066+ 0067+ 0068+ 0021 0001+ 0002+ 0003+ 0004+ 0005+ 0006+ 0007+ 0008+ 0009+ 0010+ 0011+ 0012+ 0013+ 0014+ 0015+ 0016+ 0017+ 0018+ 0019+ 0020+ 0021+ 0022+ 0023+ 0024+ 0025+ 0026+ 0027+ 0028+ 0029+ 0030+ 0031+ 0032+ 0033+ 0034+ 0035+ 0036+ 0037+ 0038+ 0039+ 0040+ 0041+ 0042+ 0043+ 0044+ 0045+

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

August 26, 1992

b.0 b.1 b.2 b.3 b.4 b.5 b.6 b.7

.equ .equ .equ .equ .equ .equ .equ .equ

0f0h 0f1h 0f2h 0f3h 0f4h 0f5h 0f6h 0f7h

; b reg bits

a.0 a.1 a.2 a.3 a.4 a.5 a.6 a.7

.equ .equ .equ .equ .equ .equ .equ .equ

0e0h 0e1h 0e2h 0e3h 0e4h 0e5h 0e6h 0e7h

; accumulator bits

rth rtl

.equ 8dh .equ 8bh

; timer 0 reload high ; timer 0 reload low

#include kbd.h #define reg .equ ; ; 8xc751 special register set ; ; 751 I2C byte registers I2CON I2CFG I2DAT I2STA

.equ .equ .equ .equ

098h 0d8h 099h 0f8h

IE

.equ 0a8h

; interrupt enable

TCON

.equ 088h

; timer/counter control

TL TH RTL RTH

.equ .equ .equ .equ

; ; ; ;

08ah 08ch 08bh 08dh

; ; ; ;

I2C I2C I2C I2C

control configuration data status

timer timer timer timer

; 751 I2C bit registers ;I2CNFG SLAVEN MASTRQ TIRUN CT1 CT0 CLRTI

.equ .equ .equ .equ .equ .equ

0dfh 0deh 0dch 0d9h 0d8h 0ddh

RDAT ATN DRDY ARL STR STP MASTER

.equ .equ .equ .equ .equ .equ .equ

09fh 09eh 09dh 09ch 09bh 09ah 099h

; I2CON CXA IDLE CDR

.equ 09fh .equ 09eh .equ 09dh

5

0 low 0 high reload low reload high

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0046+ 0047+ 0048+ 0049+ 0050+ 0051+ 0052+ 0053+ 0054+ 0055+ 0056+ 0057+ 0058+ 0059+ 0060+ 0061+ 0062+ 0063+ 0064+ 0065+ 0066+ 0067+ 0068+ 0069+ 0070+ 0071+ 0072+ 0073+ 0074+ 0075+ 0076+ 0077+ 0078+ 0079+ 0080+ 0081+ 0082+ 0083+ 0084+ 0085+ 0086+ 0087+ 0088+ 0089+ 0090+ 0091+ 0092+ 0093+ 0094+ 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

August 26, 1992

CARL CSTR CSTP XSTR XSTP

.equ .equ .equ .equ .equ

09ch 09bh 09ah 099h 098h

.equ .equ .equ .equ

0fdh 0fch 0fbh 0fah

;I2STA XDATA XACTV MAKSTR MAKSTP

; IE bit registers EA EI2 ETI EX1 ET0 EX0 ;

.equ .equ .equ .equ .equ .equ

clr set set set set set

to to to to to to

disable all interrupts enable iic interrupt enable timer 1 overflow interrupt enable ext int 1 enable timer 0 overflow interrupt enable ext int 0

.equ 02h

;CT1, CT0 bit values for I2C.

Masks for I2CFG bits.

BTIR BMRQ

;

; ; ; ; ; ;

Value definitions.

CTVAL

;

0afh 0ach 0abh 0aah 0a9h 0a8h

.equ 10h .equ 40h

; mask for TIRUN bit. ; mask for MASTRQ bit.

Masks for I2CON bits.

BCXA BIDLE BCDR BCARL BCSTR BCSTP BXSTR BXSTP ;

.equ .equ .equ .equ .equ .equ .equ .equ

80h 40h 20h 10h 08h 04h 02h 01h

; ; ; ; ; ; ; ;

mask mask mask mask mask mask mask mask

SCL SDA

.equ p0.0 .equ p0.1

; port bit for I2C serial clock line. ; port bit for I2C serial data line.

IICADD MAXBYTES

.equ 088h .equ 1

; our I2C slave address ; max bytes to recv or trans

rcvdat xmtdat

.equ 04h .equ 06h

; I2C received data buffer ; I2C transmitter buffer

STACK

.equ 08h

flags noack recvd sent_flag i2c_busy

.equ .equ .equ .equ .equ

Cntrl Shift

.equ (flags–20h)+8 ; control key flag .equ (flags–20h)+9 ; shift key flag

020h (flags–20h) (flags–20h)+1 (flags–20h)+2 (flags–20h)+3

for for for for for for for for

CXA bit. IDLE bit. CDR bit. CARL bit. CSTR bit. CSTP bit. XSTR bit. XSTP bit.

; byte used as flags ; I2C flags.0, ...1, ...2, etc ; ; ;

6

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 0090 0091 0092 0093 0094 0095 0096 0097 0098 0099 0100 0101 0102 0103 0104 0105 0106

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0002 0003 0003 0005 000B 000B 000D 0013 0013 0015 001B 001B 001D 0023 0023 0025 0025 0048 0048 0048 0048 004A 0050 0050 0050 0050 0052 0054 0056 0056 0058 005A 005C 005C 005C 005F 0062 0065 0065 0068

August 26, 1992

bitcnt bytecnt

.equ flags+2 .equ flags+3

adrrcvd rwflag

.equ flags+4 .equ (adrrcvd–20h)*8

tick i2ctime

.equ 025h .equ 027h

; count 10mS ticks to give 1sec tick ; I2C timeout – used on slow I2C bus

NBits NBytes lastkey keytemp keybuff

.equ .equ .equ .equ .equ

; ; ; ; ;

INMAX KEYCLK KEYDAT

.equ 8 .equ p1.5 .equ 82h

EDGEINT

.equ 08ah

; ;

29h NBits+1 NBytes+1 lastkey+1 keytemp+1

; adrrcvd.0

# bits read so far # bytes in buffer last key was? used to build the key bit by bit store the chars here

; size of keyboard buffer ; keyboard clock signal on ext int 0 ; keyboard data line

reset and interrupt vectors. .org 0 ajmp start

; reset vector

01 50

.org 0003h ajmp kbd

; external interrupt 0

01 B5

.org 0bh ajmp badint

; counter/timer 0

21 EA

.org 013h ajmp badint

; external interrupt 1

21 EA

.org 01bh ajmp timerI

; timer 1 – I2C timeout

21 DA

.org 023h ajmp i2cint

; I2C interrupt

21 38

.org done: 01 48

48h

ajmp $ .org

; main routine waiting for key presses

50h

start: 78 FF 79 FF 7A 04

mov r0,#0ffh mov r1,#0ffh mov r2,#04h

D8 FE D9 FC DA FA

dly1:djnz r0,$ djnz r1,dly1 djnz r2,dly1

reset: 75 80 FF 75 90 FF 75 B0 FF

mov p0,#0ffh mov p1,#0ffh mov p3,#0ffh

75 81 08 D2 8A

mov sp,#STACK setb EDGEINT

; power supply settling time

; initialize stack pointer ; make ext int 0 edge activated

7

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0107 0108 0109 0110 0111 0112 0113 0114 0115 0116 0117 0118 0119 0120 0121 0122 0123 0124 0125 0126 0127 0128 0129 0130 0131 0132 0133 0134 0135 0136 0137 0138 0139 0140 0141 0142 0143 0144 0145 0146 0147 0148 0149 0150 0151 0152 0153 0154 0155 0156 0157 0158 0159 0160 0161 0162 0163 0164 0165 0166 0167 0168 0169 0171 0172 0173 0174

006A 006A 006C 006C 006E 0070 0073 0073 0074 0075 0077 0077 0077 0077 0077 007A 007D 007D 007D 007D 0080 0083 0083 0086 0086 0086 0086 0086 0086 0088 008A 008A 008D 0090 0093 0096 0096 0096 0096 0099 0099 009C 009E 00A1 00A1 00A1 00A3 00A3 00A3 00A3 00A5 00A6 00A8 00AA 00AA 00AB 00AB 00AB 00AD 00AE 00B0 00B2 00B2 00B3 00B3 00B3 00B3

August 26, 1992

AN434

C2 09

clr Shift

; clear keyboard shift flag

78 29 79 10 75 E0 00

mov r0,#NBits mov r1,#10h mov acc,#0

; clear the input buffers

F6 08 D9 FC

clrlp:mov @r0,a inc r0 djnz r1,clrlp

; do the clearing

mov xmtdat,#’.’ mov xmtdat+1,#0ffh

; transmit buffer filled with ; $ff when empty

; ; 75 20 00 75 27 00

mov flags,#0 mov i2ctime,#0

restart: 75 D8 82 75 98 40

mov mov

75 A8 91

mov ien0,#91h

;******

I2CFG,#80h+CTVAL I2CON,#BIDLE

Main loop

; enable slave functions ; place in idle state ; enable external & IIC interrupts

******

main: E5 2A 60 0C

mov a,NBytes jz empty

; if data in keybuff then ; copy to I2C xmt buffer

75 85 75 75

mov mov mov mov

; disable all ints temporarily

A8 2D 2A A8

00 06 00 91

ien0,#0h xmtdat,keybuff NBytes,#0 ien0,#91h

; clear keyboard buffer full flag ; enable external&IIC interrupts

empty: 30 01 0A

jnb recvd,notread

85 06 E0 44 80 85 E0 06

mov acc,xmtdat orl a,#80h mov xmtdat,acc

C2 01

clr recvd

; ; ; ; ; ; ; ;

recvd flag tells 751 to clear I2C xmt buffer when I2C master reads the data from the 751 the master writes any data back which will set the MSB of the data buffer. This is reqd. to sync the two processors. reset I2C received flag

notread: E5 2B C3 94 11 70 01

mov a,lastkey clr c subb a,#11h jnz notalt

; detect alt key for special ; for special functions

00

nop

; alt code goes here

notalt: E5 2A C3 94 08 40 01

mov a,NBytes clr c subb a,#INMAX jc notdone

00

nop

; ; ; ;

sjmp main

; go back to start

limit the input buffer to INMAX if data is buffered then buffer overflow code goes here

notdone: 80 D1

8

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0175 0176 0177 0178 0179 0180 0181 0182 0183 0184 0185 0186 0187 0188 0189 0190 0191 0192 0193 0194 0195 0196 0197 0198 0199 0200 0201 0202 0203 0204 0205 0206 0207 0208 0209 0210 0211 0212 0213 0214 0215 0216 0217 0218 0219 0220 0221 0222 0223 0224 0225 0226 0227 0228 0229 0230 0231 0232 0233 0234 0235 0236 0237 0238 0239 0240 0241

00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B5 00B7 00B9 00B9 00BC 00BC 00BF 00BF 00BF 00BF 00BF 00BF 00BF 00C1 00C1 00C1 00C1 00C1 00C1 00C4 00C6 00C6 00C8 00CA 00CB 00CD 00D0 00D2 00D2 00D2 00D2 00D2 00D2 00D5 00D5 00D7 00D7 00D7 00D7 00D7 00D7 00D7 00D7 00D7 00DA 00DA 00DD 00DD 00DD 00DD 00DD 00E0 00E3 00E3 00E5

August 26, 1992

;******

End of Main loop

AN434

******

; ****** External int 0 ISR ******; ; ; ; keyboard interrupt service routine ; ; ; ; ************************************;

kbd: C0 D0 C0 E0

push psw push acc

; save .equs during ISR

85 29 E0

mov acc,NBits

B4 00 02

cjne a,#0,bit1_8

; NBits=bit number next expected ; from the keyboard ; if not bit 0 then bit 1 to 8

;****** bit0: 80 70

Keyboard Bit 0

****** ; discard bit 0 – Start bit

sjmp bump

;****** Keyboard Bit 1–8

******

bit1_8: B4 09 00 cjne a,#9,$+3 50 0C jnc bit9 A2 E5 03 92 85 80

82 2C E7 E0 2C 5F

;******

; CY flag is set if acc < 9

mov c,KEYDAT mov a,keytemp rr a mov a.7,c mov keytemp,acc sjmp bump

Bit 9

read data for keyboard data line data arrives least sig bit 1st hence old value is rotated and new bit is or’ed to the msb

******

bit9: B4 09 02

cjne a,#9,bit10

80 5A

sjmp bump

;****** Bit 10

; ; ; ;

; parity check code would go here

******

; The stop bit – Key Scan is now complete so convert to ASCII bit10: 85 2C E0

mov acc,keytemp

; get next key

B4 12 14

cjne a,#12h,notls

; is it the left shift char?

;****** Left Shift has Been Pressed

******

85 2B E0 B4 F0 07

mov acc,lastkey cjne a,#0f0h,makels

; if last key was ; $f0 then shift is released

C2 09 75 2B 12

clr Shift mov lastkey,#12h

; next keys will be unshifted ; copy left shift key to last key

9

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0242 0243 0244 0245 0246 0247 0248 0249 0250 0251 0252 0253 0254 0255 0256 0257 0258 0259 0260 0261 0262 0263 0264 0265 0266 0267 0268 0269 0270 0271 0272 0273 0274 0275 0276 0277 0278 0279 0280 0281 0282 0283 0284 0285 0286 0287 0288 0289 0290 0291 0292 0293 0294 0295 0296 0297 0298 0299 0300 0301 0302 0303 0304 0305 0306 0307 0308

00E8 80 00EA 00EA 00EA D2 00EC 75 00EF 80 00F1 00F1 00F1 00F1 00F1 00F1 B4 00F4 00F4 00F4 00F4 00F4 00 00F5 80 00F7 00F7 00F7 00F7 00F7 00F7 B4 00FA 00FA 00FA 00FA F5 00FC 80 00FE 00FE 00FE 00FE 85 0101 B4 0104 0104 75 0107 80 0109 0109 0109 0109 0109 0109 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~

August 26, 1992

3F

sjmp tidy

makels: 09 setb Shift 2B 12 mov lastkey,#12h 38 sjmp tidy

; next keys will be shifted ; copy left shift key to last key

;****** End of Shift Routine notls: ; 14 03

******

mov acc,keytemp cjne a,#14h,notctrl

;****** Control State

; get next key ; is it a control char?

******

nop sjmp tidy

32

; control state goes here

;****** End of Control State

******

notctrl: F0 04

cjne a,#0f0h,notbreak ; if current key $f0 then break

;****** 2B 2B

Key Break

******

mov lastkey,a sjmp tidy

; record break code in last key ; but don’t store in the buffer

notbreak: 2B E0 F0 05

mov acc,lastkey cjne a,#0f0h,not_f0

; if last key was $f0 then ; ignore the next scan code

2B 00 20

mov lastkey,#0 sjmp tidy

; which is a break code

not_f0:

;****** Normal Key Press

******

#ifdef buffered ;******

Buffered Code

******

; buffered code push 0

; r0 used as an indirect pointer ; so save it ; copy data into keyboard

mov acc,#keybuff add a,NBytes mov r0,a mov a,keytemp mov lastkey,a

; get current key ; & copy to lastkey

push dph push dpl

; dp used to point to xlat tables ; since in ISR save dp contents

jb Shift,shifted mov dptr,#unshift sjmp skip1

; if in unshifted state ; use the unshift table

mov dptr,#shift

; else use the shift table

shifted:

10

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0309 0310 0311 0312 0313 0314 0315 0316 0317 0318 0319 0320 0321 0322 0323 0324 0325 0326 0327 0328 0329 0330 0331 0332 0333 0334 0335 0336 0337 0338 0339 0340 0341 0342 0343 0344 0345 0346 0347 0348 0349 0350 0351 0352 0353 0354 0355 0356 0357 0358 0359 0360 0361 0362 0363 0364 0365 0366 0367 0368 0369 0370 0371 0372 0373 0374 0375

0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109~ 0109 0109 0109 0109 0109 0109 0109 0109 E5 010B F5 010D 010D C0 010F C0 0111 0111 20 0114 90 0117 80 0119 0119 0119 90 011C 011C 011C 93 011D 011D D0 011F D0 0121 0121 B4 0124 0124 0124 0124 0124 F5 0126 75 0129 0129 0129 75 012C 75 012F 80 0131 0131 0131 0131 0131 0131 0131 0131 05 0133

August 26, 1992

AN434

skip1: movc a,@a+dptr

; translate char in Acc to Ascii

pop dpl pop dph

; restore the data pointer

cjne a,#0,Not0

; if data is zero discard

; sjmp NoSave

; discard code goes here

mov r0,#keybuff mov @r0,a inc NBytes

; Save ascii value in buffer ; buffered keyboard entry

Not0:

NoSave: pop 0

; restore r0

;**** End of Buffered Code #endif

#define unbuffered 1 #ifdef unbuffered 2C 2B

mov a,keytemp mov lastkey,a

; get current key ; & copy to lastkey

83 82

push dph push dpl

; dp used to point to xlat tables ; since in ISR save dp contents

09 05 01 EB 03

jb Shift,shifted mov dptr,#unshift sjmp skip1

; if in unshifted state ; use the unshift table

shifted: 02 6B mov dptr,#shift

; else use the shift table

skip1: movc a,@a+dptr

; translate char in Acc to Ascii

82 83

pop dpl pop dph

; restore the data pointer

00 00

cjne a,#0,Not0

; if data is zero discard

; sjmp tidy

; discard code goes here

Not0: 2D 2A 01

mov keybuff,a mov NBytes,#1

; store in keyboard buffer ; mark byte read

tidy: 29 00 2C 00 02

mov NBits,#0 mov keytemp,#0 sjmp intdone

; clear flags ready for next key

;******

End of Keyboard Translation and Save

;******

Normal unfinished key exit ******

bump: 29

inc NBits

******

; inc number of bits read so far

11

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0376 0377 0378 0379 0380 0381 0382 0383 0384 0385 0386 0387 0388 0389 0390 0391 0392 0393 0394 0395 0396 0397 0398 0399 0400 0401 0402 0403 0404 0405 0406 0407 0408 0409 0410 0411 0412 0413 0414 0415 0416 0417 0418 0419 0420 0421 0422 0423 0424 0425 0426 0427 0428 0429 0430 0431 0432 0433 0434 0435 0436 0437 0438 0439 0440 0441 0442

0133 0133 0135 0137 0138 0138 0138 0138 0138 0138 0138 0138 0138 0138 013A 013A 013C 013E 0140 0140 0142 0144 0144 0144 0147 0147 014A 014A 014A 014D 0150 0150 0152 0154 0156 0159 0159 015C 015C 015C 015C 015C 015C 015E 0161 0161 0161 0163 0165 0168 0169 016A 016D 016D 016D 016D 016F 0171 0174 0177 0177 0177 0179 017B 017B 017B 017B

August 26, 1992

AN434

intdone: D0 E0 pop acc D0 D0 pop psw 32 reti ;****** End of Ext Int 0 ISR

;******

I2C CODE SLAVE

******

******

i2cint: D2 03 setb i2c_busy

; I2C interrupt entry point ; semaphore on xmtdata buffer

C0 D0 C0 E0 C0 00

push psw push acc push 0

; save registers used in ISR

C2 AC 31 E9

clr EI2 acall clrint

; make I2C ISR interruptable ; execute a reti

slave: 75 27 03

mov i2ctime,#3

; set up I2C timeout watchdog 30 mS

; R0 no bank switching

75 98 9C

mov I2CON,#BCARL+BCSTP+BCSTR+BCXA ; clear start status

30 9E FD 75 22 07

jnb ATN,$ mov bitcnt,#7

; wait for next data bit

31 F5 C2 B4

acall recvb2 mov adrrcvd,a clr a.0 cjne a,#IICADD,goidle

; get remainder of slave address

jb rwflag,read

; test for read or write

C9 24 E0 88 3B

20 20 1F

;****** I2C Receive Code 78 04 75 23 01

31 31 30 F6 08 D5

; mask r/w bit to check address ; idle again if not for us

******

mov r0,#rcvdat mov bytecnt,#MAXBYTES

; r0 points to data buffer

rcvloop: BF acall sendack C6 acall rcvbyte 9D 0F jnb DRDY,exitwr mov @r0,a inc r0 23 F4 djnz bytecnt,rcvloop

; acknowledge the address ; wait for the next data byte ; end of frame

; no more room 31 31 75 30

BF C6 99 80 9E FD exitwr:

D2 01 80 13 ;******

acall sendack acall rcvbyte mov I2DAT,#80h jnb ATN,$

; ; ; ;

setb recvd sjmp msgend End of Receive Routine

******

12

ack last byte get but discard next one send neg ack wait till gone

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0443 0444 0445 0446 0447 0448 0449 0450 0451 0452 0453 0454 0455 0456 0457 0458 0459 0460 0461 0462 0463 0464 0465 0466 0467 0468 0469 0470 0471 0472 0473 0474 0475 0476 0477 0478 0479 0480 0481 0482 0483 0484 0485 0486 0487 0488 0489 0490 0491 0492 0493 0494 0495 0496 0497 0498 0499 0500 0501 0502 0503 0504 0505 0506 0507 0508 0509

017B 017B 017B 017B 017D 0180 0182 0182 0182 0183 0184 0186 0189 018C 018C 018E 018E 018E 018E 018E 018E 018E 0191 0194 0194 0194 0194 0194 0197 019A 019A 019C 019E 01A0 01A0 01A2 01A4 01A6 01A6 01A7 01A7 01A7 01A7 01A7 01A7 01AA 01AA 01AA 01AC 01AD 01B0 01B3 01B6 01B9 01BC 01BD 01BD 01BD 01BD 01BD 01BF 01BF 01BF 01C2 01C5 01C6 01C6

August 26, 1992

;****** I2C Transmit Code

AN434

******

read: 78 06 75 23 01 31 BF

mov r0,#xmtdat mov bytecnt,#MAXBYTES acall sendack

; r0 points to data buffer

txloop: E6 08 31 A7 20 00 03 D5 23 F6

mov a,@r0 inc r0 acall xmitbyte jb noack,exitrd djnz bytecnt,txloop

; ; ; ;

80 00

exitrd: sjmp msgend

;****** End of I2C transmit

; acknowledge address

get next data byte bump buffer pointer transmit the byte to the I2C if not acknowledged then exit

******

;****** Repeated start state msgend: 30 9E FD jnb ATN,$ 20 9B B0 jb STR,slave

****** ; wait for stop or repeated start ; if repeat start do again

; stop so enter idle mode goidle: 75 27 00 mov i2ctime,#0 ; stop I2C timeout 75 98 F4 mov I2CON,#BCSTP+BCXA+BCDR+BCARL+BIDLE D0 00 D0 E0 D0 D0

pop 0 pop acc pop psw

D2 AC D2 02 C2 03

setb EI2 setb sent_flag clr i2c_busy

22

ret

;******

; restore state before I2C ISR

General I2C routines

; flag to say data has been sent ; flag denotes exiting I2C routine

******

xmitbyte: 75 22 08 mov bitcnt,#8

F5 23 30 D5 75 30 85 22

; transmit data in acc to I2C

xmitbit: 99 mov I2DAT,a rl a 9E FD jnb ATN,$ 22 F7 djnz bitcnt,xmitbit 98 A0 mov I2CON,#BCDR+BCXA ; switch to rcv mode 9E FD jnb ATN,$ ; wait for ack 99 20 mov flags,I2DAT ; save ack bit ret

rdack: 31 C6

; receives data byte then sends ack ; I2C receive, data returned in acc

acall rcvbyte

sendack: 75 99 00 mov I2DAT,#0 30 9E FD jnb ATN,$ 22 ret

; I2C ack = data low and clock high

rcvbyte:

; I2C receive, data returned in acc

13

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0510 0511 0512 0513 0514 0515 0516 0517 0518 0519 0520 0521 0522 0523 0524 0525 0526 0527 0528 0529 0530 0531 0532 0533 0534 0535 0536 0537 0538 0539 0540 0541 0542 0543 0544 0545 0546 0547 0001+ 0002+ 0003+ 0004+ 0005+ 0006+ 0007+ 0008+ 0009+ 0010+ 0011+ 0012+ 0013+ 0014+ 0015+ 0016+ 0017+ 0018+ 0019+ 0020+ 0021+ 0022+ 0023+ 0024+ 0025+ 0026+ 0027+ 0028+ 0029+

01C6 01C9 01C9 01CA 01CA 01CC 01CD 01D0 01D3 01D6 01D6 01D8 01D9 01D9 01D9 01DA 01DA 01DA 01DA 01DD 01DF 01DF 01E2 01E5 01E5 01E7 01E9 01E9 01E9 01E9 01E9 01E9 01EA 01EA 01EA 01EA 01EB 01EB 01EB 01EB 01EC 01ED 01EE 01EF 01F0 01F1 01F2 01F3 01F4 01F5 01F6 01F7 01F8 01F9 01FA 01FB 01FB 01FC 01FD 01FE 01FF 0200 0201 0202 0203 0204 0205

August 26, 1992

75 22 08

mov bitcnt,#8

E4

recvb2: clr a

45 23 30 30 D5

99 9E FD 9D 06 22 F4

A2 9F 33

rbit: orl a,I2DAT rl a jnb ATN,$ jnb DRDY,rbex djnz bitcnt,rbit

AN434

; exit if not a data bit

mov c,RDAT rlc a

; get last bit – do not clear ATN ; shift into byte

rbex: 22

75 D2 75 75

ret ; timerI: A8 00 DD fixup: D8 00 98 BC

31 E9 01 5C

;******

IIC timer interrupt service mov ien0,#0 setb CLRTI

; break point address in ICE751 ; clear the interrupt

mov I2CFG,#0 ; turn off I2C mov I2CON,#BCXA+BCDR+BCARL+BCSTR+BCSTP ; reset I2C flags acall clrint ajmp reset ; restart program

call here to make code interruptible

******

clrint: 32

reti ;****** badint:

32

00 00 00 00 00 00 00 00 00 00 00 00 00 09 60 00 00 00 00 00 00 71 31 00 00 00 7A

unused interrupts are vectored to here reti

#include attable.h unshift .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 0 .byte 09h .byte ’‘’ .byte 0 .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 0 0 ’q’ ’1’ 0 0 0 ’z’

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

scan code 0 1 – f9 2 – f7 3 – f5 4 – f3 5 – f1 6 – f2 7 – f2 8 – 9 – f10 a – f8 b – f6 c – f4 d – tab e – ‘ f –

; ; ; ; ; ; ; ; ; ; ;

10 11 – left shift 12 13 14 15 16 17 18 19 1a

14

******

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0030+ 0031+ 0032+ 0033+ 0034+ 0035+ 0036+ 0037+ 0038+ 0039+ 0040+ 0041+ 0042+ 0043+ 0044+ 0045+ 0046+ 0047+ 0048+ 0049+ 0050+ 0051+ 0052+ 0053+ 0054+ 0055+ 0056+ 0057+ 0058+ 0059+ 0060+ 0061+ 0062+ 0063+ 0064+ 0065+ 0066+ 0067+ 0068+ 0069+ 0070+ 0071+ 0072+ 0073+ 0074+ 0075+ 0076+ 0077+ 0078+ 0079+ 0080+ 0081+ 0082+ 0083+ 0084+ 0085+ 0086+ 0087+ 0088+ 0089+ 0090+ 0091+ 0092+ 0093+ 0094+ 0095+ 0096+

0206 0207 0208 0209 020A 020B 020B 020C 020D 020E 020F 0210 0211 0212 0213 0214 0215 0216 0217 0218 0219 021A 021B 021B 021C 021D 021E 021F 0220 0221 0222 0223 0224 0225 0226 0227 0228 0229 022A 022B 022B 022C 022D 022E 022F 0230 0231 0232 0233 0234 0235 0236 0237 0238 0239 023A 023B 023B 023C 023D 023E 023F 0240 0241 0242 0243 0244

August 26, 1992

73 61 77 32 00

.byte .byte .byte .byte .byte

’s’ ’a’ ’w’ ’2’ 0

; ; ; ; ;

1b 1c 1d 1e 1f

00 63 78 64 65 34 33 00 00 20 76 66 74 72 35 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’c’ ’x’ ’d’ ’e’ ’4’ ’3’ 0 0 ’ ’ ’v’ ’f’ ’t’ ’r’ ’5’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

00 6E 62 68 67 79 36 00 00 00 6D 6A 75 37 38 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’n’ ’b’ ’h’ ’g’ ’y’ ’6’ 0 0 0 ’m’ ’j’ ’u’ ’7’ ’8’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f

00 2C 6B 69 6F 30 39 00 00 2E 2F 6C 00 70 2D 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’,’ ’k’ ’i’ ’o’ ’0’ ’9’ 0 0 ’.’ ’/’ ’l’ ’;’ ’p’ ’–’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

00 2C 00 00 5B 3D 00 00 00 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’,’ 0 0 ’[’ ’=’ 0 0 0 0

; ; ; ; ; ; ; ; ; ;

50 51 52 53 54 55 56 57 58 59

15

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0097+ 0098+ 0099+ 0100+ 0101+ 0102+ 0103+ 0104+ 0105+ 0106+ 0107+ 0108+ 0109+ 0110+ 0111+ 0112+ 0113+ 0114+ 0115+ 0116+ 0117+ 0118+ 0119+ 0120+ 0121+ 0122+ 0123+ 0124+ 0125+ 0126+ 0127+ 0128+ 0129+ 0130+ 0131+ 0132+ 0133+ 0134+ 0135+ 0136+ 0137+ 0138+ 0139+ 0140+ 0141+ 0142+ 0143+ 0144+ 0145+ 0146+ 0147+ 0148+ 0149+ 0150+ 0151+ 0152+ 0153+ 0154+ 0155+ 0156+ 0157+ 0158+ 0159+ 0160+ 0161+ 0162+ 0163+

0245 0246 0247 0248 0249 024A 024B 024B 024C 024D 024E 024F 0250 0251 0252 0253 0254 0255 0256 0257 0258 0259 025A 025B 025B 025C 025D 025E 025F 0260 0261 0262 0263 0264 0265 0266 0267 0268 0269 026A 026B 026B 026B 026C 026D 026E 026F 0270 0271 0272 0273 0274 0275 0276 0277 0278 0279 027A 027B 027B 027C 027D 027E 027F 0280 0281 0282

August 26, 1992

0D 5D 00 5C 00 00

.byte .byte .byte .byte .byte .byte

13 ’]’ 0 92 0 0

; ; ; ; ; ;

5a 5b 5c 5d 5e 5f

00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f

00 7F 00 00 00 1B 00 00 00 2B 00 2D 2A 00 00 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 127 0 0 0 27 0 0 0 ’+’ 0 ’–’ ’*’ 0 0 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f

00 00 00 00 00 00 00 00 00 00 00 00 00 00 7E 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 0 0 0 0 0 0 0 0 0 0 0 ’~’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

scan code 0 1 – f9 2 – f7 3 – f5 4 – f3 5 – f1 6 – f2 7 – f2 8 – 9 – f10 a – f8 b – f6 c – f4 d – tab e – ~ f –

00 00 00 00 00 51 21 00

.byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 0 0 ’Q’ ’!’ 0

; ; ; ; ; ; ; ;

10 11 – 12 13 14 15 16 17

shift:

16

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0164+ 0165+ 0166+ 0167+ 0168+ 0169+ 0170+ 0171+ 0172+ 0173+ 0174+ 0175+ 0176+ 0177+ 0178+ 0179+ 0180+ 0181+ 0182+ 0183+ 0184+ 0185+ 0186+ 0187+ 0188+ 0189+ 0190+ 0191+ 0192+ 0193+ 0194+ 0195+ 0196+ 0197+ 0198+ 0199+ 0200+ 0201+ 0202+ 0203+ 0204+ 0205+ 0206+ 0207+ 0208+ 0209+ 0210+ 0211+ 0212+ 0213+ 0214+ 0215+ 0216+ 0217+ 0218+ 0219+ 0220+ 0221+ 0222+ 0223+ 0224+ 0225+ 0226+ 0227+ 0228+ 0229+ 0230+

0283 0284 0285 0286 0287 0288 0289 028A 028B 028B 028C 028D 028E 028F 0290 0291 0292 0293 0294 0295 0296 0297 0298 0299 029A 029B 029B 029C 029D 029E 029F 02A0 02A1 02A2 02A3 02A4 02A5 02A6 02A7 02A8 02A9 02AA 02AB 02AB 02AC 02AD 02AE 02AF 02B0 02B1 02B2 02B3 02B4 02B5 02B6 02B7 02B8 02B9 02BA 02BB 02BB 02BC 02BD 02BE 02BF 02C0 02C1

August 26, 1992

00 00 5A 53 41 57 40 00

.byte .byte .byte .byte .byte .byte .byte .byte

0 0 ’Z’ ’S’ ’A’ ’W’ ’@’ 0

; ; ; ; ; ; ; ;

18 19 1a 1b 1c 1d 1e 1f

00 43 58 44 45 24 23 00 00 20 56 46 54 52 25 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’C’ ’X’ ’D’ ’E’ ’$’ ’#’ 0 0 ’ ’ ’V’ ’F’ ’T’ ’R’ ’’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ;

00 4E 42 48 47 59 5E 00 00 00 4D 4A 55 26 2A 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’N’ ’B’ ’H’ ’G’ ’Y’ ’^’ 0 0 0 ’M’ ’J’ ’U’ ’&’ ’*’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f

00 3C 4B 49 4F 29 28 00 00 3E 3F 4C 3A 50 5F 00

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 ’’ ’?’ ’L’ ’:’ ’P’ ’_’ 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

00 00 22 00 7B 2B 00

.byte .byte .byte .byte .byte .byte .byte

0 0 ’”’ 0 ’{’ ’+’ 0

; ; ; ; ; ; ;

50 51 52 53 54 55 56

20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d ; 2e ; 2f

17

AN434

Philips Semiconductors Microcontroller Products

Application note

Connecting a PC keyboard to the I2C-bus

0231+ 02C2 00 0232+ 02C3 00 0233+ 02C4 00 0234+ 02C5 0D 0235+ 02C6 7D 0236+ 02C7 00 0237+ 02C8 7C 0238+ 02C9 00 0239+ 02CA 00 0240+ 02CB 0241+ 02CB 00 0242+ 02CC 00 0243+ 02CD 00 0244+ 02CE 00 0245+ 02CF 00 0246+ 02D0 00 0247+ 02D1 08 0248+ 02D2 00 0249+ 02D3 00 0250+ 02D4 31 0251+ 02D5 00 0252+ 02D6 34 0253+ 02D7 37 0254+ 02D8 00 0255+ 02D9 00 0256+ 02DA 00 0257+ 02DB 0258+ 02DB 30 0259+ 02DC 2E 0260+ 02DD 32 0261+ 02DE 35 0262+ 02DF 36 0263+ 02E0 38 0264+ 02E1 1B 0265+ 02E2 00 0266+ 02E3 00 0267+ 02E4 2B 0268+ 02E5 33 0269+ 02E6 2D 0270+ 02E7 00 0271+ 02E8 39 0272+ 02E9 00 0273+ 02EA 00 0274+ 02EB 0275+ 02EB 0548 02EB 0549 02EB tasm: Number of errors

August 26, 1992

.byte .byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 13 ’}’ 0 ’|’ 0 0

; ; ; ; ; ; ; ; ;

57 58 59 5a 5b 5c 5d 5e 5f

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

0 0 0 0 0 0 8 0 0 ’1’ 0 ’4’ ’7’ 0 0 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f

.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte

’0’ ’.’ ’2’ ’5’ ’6’ ’8’ 27 0 0 ’+’ ’3’ ’–’ 0 ’9’ 0 0

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f

.end = 0

18

AN434