The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

Connecting keyboard I2C-bus AN434 CONNECTING KEYBOARD T


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet




Connecting keyboard I2C-bus
AN434
CONNECTING KEYBOARD
This application note illustrates low-cost 8-bit microcontroller-the 8XC751-to interface standard PC/AT keyboard bus. 8XC751 (83C751 ROM-version, 87C571 EPROM-version) ideally suited task thanks built-in interface, small form-factor (24-pin 28-pin PLCC) power consumption (11mA typical MHz; Figure application software easily fits within bytes code bytes data memory provided 8XC751.
Keyboard-to-I2C Hardware (Figure
8XC751 on-chip interface allows direct connection (Serial Data) (Serial Clock) pins corresponding lines. Since open collector (allowing multimasters), resistors used pull lines idle state between keypresses. PC/AT keyboard interface equally simple. output from keyboard used generate interrupt (INT0). response, 8XC751 interrupt service routine samples keyboard serial DATA connected port (P0.2). When used with keyboard implements bidirectional communication protocol exploiting fact that both keyboard drive open collector DATA lines. However, bidirectional communication required basic keyboard operation this application, keyboard treated `input-only' device.
example, keyboard SHIFT-MAKE, `A'-MAKE, SHIFT-BREAK, `A'-BREAK sequence converted ASCII code uppercase (41H). flowchart Figure depicts keyboard data capture code conversion process. 8XC751 operates slave. When master issues read command, 8XC751 returns converted ASCII character. seven least significant bits used ASCII code, while most significant used flag new, old). code remains marked until master issues write 8XC751 which point marked will overwritten next processed. keyboard-to-I2C software shown immediately following Figure Less than half code space available 8XC751 used, leaving room extra features such parity checking more complete keyboard control state mapping using additional look-up tables.
PC/AT Keyboard
PC/AT keyboard transmits data clocked serial format consisting start bit, data bits (LSB first), parity stop shown Figure Besides clock data, 5-pin connector (Figure also includes power, ground connect. Note that PS/2 keyboard interface logically equivalent, though uses different connector. sixth provides additional connect). When pressed, PC/AT keyboard transmits `make' code and, when released, `break' code. make code consists 8-bit `scan' code denoting pressed. `break' code (key released) consists same 8-bit scan code preceded special code-0F0H. notable difference from regular ASCII keyboard SHIFT, CTRL, ALT, etc. control keys work. ASCII keyboard, control keys directly modify code output. example, (ASCII code `a') output pressed itself, while (ASCII code `A') output SHIFT keys pressed simultaneously. PC/AT keyboard handles such combination separate presses, i.e., SHIFT-MAKE, `A'-MAKE, SHIFT-BREAK, `A'-BREAK. scan code (1CH) same both shifted unshifted state. determine whether scan code interpreted must keep track presence absence prior SHIFT-MAKE.
Keyboard-to-I2C Software
keyboard-to-I2C software performs three major functions:
P3.4/A4 P3.3/A3 P3.2/A2/A10 P3.1/A1/A9 P3.0/A0/A8 P0.2/VPP P0.1/SDA/ OE-PGM P0.0/SCL/ ASEL P3.5/A5 P3.6/A6 P3.7/A7 P1.7/T0/D7 P1.6/INT1/D6 P1.5/INT0/D5 P1.4/D4 P1.3/D3 P1.2/D2 P1.1/D1 P1.0/D0
Capture clocked serial data from
keyboard
Translate keyboard data
corresponding ASCII code
Send ASCII code message.
When pressed, output from keyboard generates interrupt INT0. 8XC751 shifts DATA from keyboard P0.2 (port extracts 8-bit scan code from 11-bit packet. Next, scan code interpreted converted corresponding ASCII code using look-up table. Keyboard multi-code outputs converted single ASCII codes tracking state (i.e. shifted unshifted) keyboard using separate look-up tables each.
Figure Configuration
August 1992
Connecting keyboard I2C-bus
AN434
DATA
start
parity
stop
20µs typ. 80µs typ. Figure PC/AT Keyboard Timing
RESET
CLOCK
VOLTS
DATA
Figure Keyboard Connections (looking into connector)
KEYBOARD CONNECTOR
11.06MHz 33pF P0.2
DATA
INT0
33pF
Figure Keyboard Format Using 8XC751
August 1992
Connecting keyboard I2C-bus
AN434
Save registers
BIT#
Bit#=1
Shift keyboard DATA line (P0.2) into variable KEY.
Bit#=9
Parity check (optional)
KEY=SHIFT
LASTKEY BREAK code
SHIFT flag
Clear SHIFT flag CTRL handling (optional)
KEY=CTRL
KEY=BREAK code
LASTKEY=BREAK code
LASTKEY BREAK code
LASTKEY=KEY
SHIFT flag
Translate ASCII using `shifted' look-up table
Translate ASCII using `unshifted look-up table
BIT#=0
BIT#=BIT#+1
Restore Registers
Figure Keyboard Data Capture Conversion August 1992
Connecting keyboard I2C-bus
AN434
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
Copyright Micro AMPS Philips Semiconductors 1990 Read data under interrupt from keyboard Hardware resources: clock interrupt INT0 P1.5 data P0.2
This program reads keys from keyboard translates them ASCII
#include equates.51 direct addresses standard 8051 processor pcon tcon tmod scon s0con s0buf ien0 .equ .equ .equ .equ .equ .equ .equ .equ .equ port stack pointer data pointer data pointer high power timer timer timer timer control control mode high
.equ .equ .equ .equ .equ .equ .equ .equ .equ 0a0h 0b0h 0a8h 0a8h
timer high port serial control serial control serial data
port port interrupt enable
.equ 0d0h .equ 0e0h .equ 0f0h
program status word accumulator register
addressed flags ien0.7 p0.0 .equ .equ .equ .equ .equ .equ .equ .equ timer timer timer timer edge/level trigger edge detect edge/level trigger edge detect enable/disable overflow detect enable/disable overflow detect
.equ .equ .equ 0afh .equ 080h global enable/disable port
August 1992
Connecting keyboard I2C-bus
AN434
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
.equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ
0f0h 0f1h 0f2h 0f3h 0f4h 0f5h 0f6h 0f7h 0e0h 0e1h 0e2h 0e3h 0e4h 0e5h 0e6h 0e7h
bits
accumulator bits
.equ .equ
timer reload high timer reload
#include kbd.h #define .equ 8xc751 special register byte registers I2CON I2CFG I2DAT I2STA TCON .equ .equ .equ .equ 098h 0d8h 099h 0f8h control configuration data status
.equ 0a8h .equ 088h .equ .equ .equ .equ 08ah 08ch 08bh 08dh
interrupt enable timer/counter control timer timer timer timer high reload reload high
registers ;I2CNFG SLAVEN MASTRQ TIRUN CLRTI RDAT DRDY MASTER I2CON IDLE .equ 09fh .equ 09eh .equ 09dh .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ .equ 0dfh 0deh 0dch 0d9h 0d8h 0ddh 09fh 09eh 09dh 09ch 09bh 09ah 099h
August 1992
Connecting keyboard I2C-bus
AN434
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
CARL CSTR CSTP XSTR XSTP ;I2STA XDATA XACTV MAKSTR MAKSTP
.equ .equ .equ .equ .equ
09ch 09bh 09ah 099h 098h
.equ .equ .equ .equ
0fdh 0fch 0fbh 0fah
registers .equ .equ .equ .equ .equ .equ 0afh 0ach 0abh 0aah 0a9h 0a8h disable interrupts enable interrupt enable timer overflow interrupt enable enable timer overflow interrupt enable
Value definitions. .equ ;CT1, values I2C.
CTVAL
Masks I2CFG bits. .equ .equ mask TIRUN bit. mask MASTRQ bit.
BTIR BMRQ
Masks I2CON bits. .equ .equ .equ .equ .equ .equ .equ .equ mask mask mask mask mask mask mask mask bit. IDLE bit. bit. CARL bit. CSTR bit. CSTP bit. XSTR bit. XSTP bit.
BCXA BIDLE BCDR BCARL BCSTR BCSTP BXSTR BXSTP
.equ p0.0 .equ p0.1
port serial clock line. port serial data line.
IICADD MAXBYTES rcvdat xmtdat STACK flags noack recvd sent_flag i2c_busy Cntrl Shift
.equ 088h .equ .equ .equ .equ .equ .equ .equ .equ .equ
slave address bytes recv trans received data buffer transmitter buffer
020h (flags-20h) (flags-20h)+1 (flags-20h)+2 (flags-20h)+3
byte used flags flags.0,
.equ (flags-20h)+8 control flag .equ (flags-20h)+9 shift flag
August 1992
Connecting keyboard I2C-bus
AN434
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
bitcnt bytecnt adrrcvd rwflag tick i2ctime
.equ flags+2 .equ flags+3 .equ flags+4 .equ (adrrcvd-20h)*8 .equ 025h .equ 027h
adrrcvd.0
count 10mS ticks give 1sec tick timeout used slow
NBits NBytes lastkey keytemp keybuff
.equ .equ .equ .equ .equ
NBits+1 NBytes+1 lastkey+1 keytemp+1
bits read bytes buffer last was? used build store chars here
INMAX KEYCLK KEYDAT EDGEINT
.equ .equ p1.5 .equ .equ 08ah
size keyboard buffer keyboard clock signal keyboard data line
reset interrupt vectors. .org ajmp start .org 0003h ajmp .org ajmp badint .org 013h ajmp badint .org 01bh ajmp timerI .org 023h ajmp i2cint reset vector
external interrupt
counter/timer
external interrupt
timer timeout
interrupt
.org done:
ajmp .org
main routine waiting presses
start: reset:
r0,#0ffh r1,#0ffh r2,#04h dly1:djnz r0,$ djnz r1,dly1 djnz r2,dly1
power supply settling time
p0,#0ffh p1,#0ffh p3,#0ffh sp,#STACK setb EDGEINT initialize stack pointer make edge activated
August 1992
Connecting keyboard I2C-bus
AN434
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
restart:
Shift r0,#NBits r1,#10h acc,#0 clrlp:mov @r0,a djnz r1,clrlp xmtdat,#'.' xmtdat+1,#0ffh flags,#0 i2ctime,#0
clear keyboard shift flag clear input buffers
clearing
transmit buffer filled with when empty
I2CFG,#80h+CTVAL I2CON,#BIDLE
enable slave functions place idle state enable external interrupts
ien0,#91h
;****** main:
Main loop
******
a,NBytes empty ien0,#0h xmtdat,keybuff NBytes,#0 ien0,#91h
data keybuff then copy buffer disable ints temporarily clear keyboard buffer full flag enable external&IIC interrupts
empty: recvd,notread acc,xmtdat a,#80h xmtdat,acc recvd flag tells clear buffer when master reads data from master writes data back which will data buffer. This reqd. sync processors. reset received flag
notread: notalt: notdone:
recvd
a,lastkey subb a,#11h notalt
detect special special functions
code goes here
a,NBytes subb a,#INMAX notdone
limit input buffer INMAX data buffered then buffer overflow code goes here
sjmp main
back start
August 1992
Connecting keyboard I2C-bus
AN434
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
;******
Main loop
******
****** External ******; keyboard interrupt service routine
kbd:
push push acc,NBits cjne a,#0,bit1_8
save .equs during
NBits=bit number next expected from keyboard then
;****** bit0:
Keyboard
****** discard Start
sjmp bump
;****** Keyboard bit1_8: cjne a,#9,$+3 bit9 c,KEYDAT a,keytemp a.7,c keytemp,acc sjmp bump
******
flag
read data keyboard data line data arrives least hence value rotated or'ed
;****** bit9:
******
cjne a,#9,bit10 sjmp bump parity check code would here
;******
******
stop Scan complete convert ASCII bit10:
acc,keytemp cjne a,#12h,notls
next left shift char?
;****** Left Shift Been Pressed acc,lastkey cjne a,#0f0h,makels Shift lastkey,#12h
****** last then shift released next keys will unshifted copy left shift last
August 1992
Connecting keyboard I2C-bus
AN434
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 00EA 00EA 00EA 00EC 00EF 00F1 00F1 00F1 00F1 00F1 00F1 00F4 00F4 00F4 00F4 00F4 00F5 00F7 00F7 00F7 00F7 00F7 00F7 00FA 00FA 00FA 00FA 00FC 00FE 00FE 00FE 00FE 0101 0104 0104 0107 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~
sjmp tidy
makels: setb Shift lastkey,#12h sjmp tidy ;****** Shift Routine notls: ******
next keys will shifted copy left shift last
acc,keytemp cjne a,#14h,notctrl
next control char?
;****** Control State sjmp tidy
****** control state goes here
;****** Control State notctrl: ;******
******
cjne a,#0f0h,notbreak current then break Break ****** record break code last don't store buffer
lastkey,a sjmp tidy
notbreak: not_f0: acc,lastkey cjne a,#0f0h,not_f0 lastkey,#0 sjmp tidy last then ignore next scan code which break code
;****** Normal Press #ifdef buffered ;****** Buffered Code
******
******
buffered code push acc,#keybuff a,NBytes r0,a a,keytemp lastkey,a push push Shift,shifted dptr,#unshift sjmp skip1 shifted: dptr,#shift
used indirect pointer save copy data into keyboard
current copy lastkey used point xlat tables since save contents unshifted state unshift table
else shift table
August 1992
Connecting keyboard I2C-bus
AN434
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 010B 010D 010D 010F 0111 0111 0114 0117 0119 0119 0119 011C 011C 011C 011D 011D 011F 0121 0121 0124 0124 0124 0124 0124 0126 0129 0129 0129 012C 012F 0131 0131 0131 0131 0131 0131 0131 0131 0133
skip1: movc a,@a+dptr cjne a,#0,Not0 sjmp NoSave Not0: r0,#keybuff @r0,a NBytes NoSave: restore Save ascii value buffer buffered keyboard entry translate char Ascii restore data pointer
data zero discard discard code goes here
;**** Buffered Code #endif
#define unbuffered #ifdef unbuffered a,keytemp lastkey,a push push Shift,shifted dptr,#unshift sjmp skip1 current copy lastkey used point xlat tables since save contents unshifted state unshift table
shifted: dptr,#shift skip1: movc a,@a+dptr cjne a,#0,Not0 sjmp tidy Not0: tidy: ;******
else shift table
translate char Ascii restore data pointer
data zero discard discard code goes here
keybuff,a NBytes,#1
store keyboard buffer mark byte read
NBits,#0 keytemp,#0 sjmp intdone
clear flags ready next
Keyboard Translation Save
******
;****** bump:
Normal unfinished exit ******
NBits
number bits read
August 1992
Connecting keyboard I2C-bus
AN434
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
intdone: reti ;****** ******
;******
CODE SLAVE
****** interrupt entry point semaphore xmtdata buffer save registers used bank switching make interruptable execute reti
i2cint: setb i2c_busy slave: push push push acall clrint
i2ctime,#3
timeout watchdog
I2CON,#BCARL+BCSTP+BCSTR+BCXA clear start status ATN,$ bitcnt,#7 acall recvb2 adrrcvd,a cjne a,#IICADD,goidle rwflag,read wait next data
remainder slave address mask check address idle again test read write
;****** Receive Code
****** points data buffer
r0,#rcvdat bytecnt,#MAXBYTES
rcvloop: acall sendack acall rcvbyte DRDY,exitwr @r0,a djnz bytecnt,rcvloop more room
acknowledge address wait next data byte frame
exitwr:
acall sendack acall rcvbyte I2DAT,#80h ATN,$
last byte discard next send wait till gone
;******
setb recvd sjmp msgend Receive Routine ******
August 1992
Connecting keyboard I2C-bus
AN434
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
;****** Transmit Code read: txloop:
******
r0,#xmtdat bytecnt,#MAXBYTES acall sendack
points data buffer acknowledge address
a,@r0 acall xmitbyte noack,exitrd djnz bytecnt,txloop exitrd: sjmp msgend ******
next data byte bump buffer pointer transmit byte acknowledged then exit
;****** transmit
;****** Repeated start state msgend: ATN,$ STR,slave stop enter idle mode
****** wait stop repeated start repeat start again
goidle: i2ctime,#0 stop timeout setb setb sent_flag i2c_busy restore state before
flag data been sent flag denotes exiting routine
;******
General routines
****** transmit data
xmitbyte: bitcnt,#8
xmitbit: I2DAT,a ATN,$ djnz bitcnt,xmitbit I2CON,#BCDR+BCXA switch mode ATN,$ wait flags,I2DAT save
rdack:
acall rcvbyte
receives data byte then sends receive, data returned
sendack: I2DAT,#0 ATN,$ rcvbyte:
data clock high
receive, data returned
August 1992
Connecting keyboard I2C-bus
AN434
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
bitcnt,#8 recvb2: rbit: a,I2DAT ATN,$ DRDY,rbex djnz bitcnt,rbit c,RDAT
exit data
rbex: timerI: fixup:
last clear shift into byte
timer interrupt service ien0,#0 setb CLRTI break point address ICE751 clear interrupt
I2CFG,#0 turn reset flags acall clrint ajmp reset restart program
;****** clrint: ;****** badint:
call here make code interruptible
******
reti unused interrupts vectored here reti #include attable.h unshift .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte ******
scan code left shift
August 1992
Connecting keyboard I2C-bus
AN434
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
.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte
August 1992
Connecting keyboard I2C-bus
AN434
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
shift:
.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte
scan code
.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte
August 1992
Connecting keyboard I2C-bus
AN434
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
.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte
August 1992
Connecting keyboard I2C-bus
AN434
0231+ 02C2 0232+ 02C3 0233+ 02C4 0234+ 02C5 0235+ 02C6 0236+ 02C7 0237+ 02C8 0238+ 02C9 0239+ 02CA 0240+ 02CB 0241+ 02CB 0242+ 02CC 0243+ 02CD 0244+ 02CE 0245+ 02CF 0246+ 02D0 0247+ 02D1 0248+ 02D2 0249+ 02D3 0250+ 02D4 0251+ 02D5 0252+ 02D6 0253+ 02D7 0254+ 02D8 0255+ 02D9 0256+ 02DA 0257+ 02DB 0258+ 02DB 0259+ 02DC 0260+ 02DD 0261+ 02DE 0262+ 02DF 0263+ 02E0 0264+ 02E1 0265+ 02E2 0266+ 02E3 0267+ 02E4 0268+ 02E5 0269+ 02E6 0270+ 02E7 0271+ 02E8 0272+ 02E9 0273+ 02EA 0274+ 02EB 0275+ 02EB 0548 02EB 0549 02EB tasm: Number errors
.byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte .byte
.end
August 1992

Other recent searches


ST92195B - ST92195B   ST92195B Datasheet
REJ03B0160-0122 - REJ03B0160-0122   REJ03B0160-0122 Datasheet
N24D - N24D   N24D Datasheet
MRF6S18140H - MRF6S18140H   MRF6S18140H Datasheet
LM193 - LM193   LM193 Datasheet
LM293 - LM293   LM293 Datasheet
LM293A - LM293A   LM293A Datasheet
LM393 - LM393   LM393 Datasheet
LM393A - LM393A   LM393A Datasheet
LM2903 - LM2903   LM2903 Datasheet
LM2903V - LM2903V   LM2903V Datasheet
IRF2807SPbF - IRF2807SPbF   IRF2807SPbF Datasheet
IRF2807LPbF - IRF2807LPbF   IRF2807LPbF Datasheet
BFP181T - BFP181T   BFP181T Datasheet
BFP181TW - BFP181TW   BFP181TW Datasheet
BFP181TRW - BFP181TRW   BFP181TRW Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive