Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Keybord Interfacing with AT89C2051 Microcontroller

Status
Not open for further replies.

girish2k44

Newbie level 3
Joined
Sep 16, 2009
Messages
3
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
India
Activity points
1,304
AT Keybord Interfacing

Hi
I am interfacing a keyboard with AT89C2051 Microcontroller
This Microcontroller works as a Encoder in between AT Keyboard and 8085 based system
the code conversion is not similar to SCAN codes to ASCII it uses different table which i
captured with the help of Logic Analyser. I am successful in sending data and show on display of 8085 LCD based Trainer but still my programmed controller is not working as the real one it is slower and sometimes print same data on single press and sometimes repeat data.
In hardware Keyboard clock is connected to P3.1 which also works as serial Transmission (TX),
Keyboard Data pin is connected to P3.0 which also works as Receive Pin for Serial Data.
So I am in confusion wheteher the Original programmed controller is collecting data using SBUF register or as a Normal port by bit shifting method as i have programmed my controller using PORT3 as normal Input port and none of the SFR register is used
I am attaching my Code and hardware schematic and one more thing when keyboard clock is completed after key press a pin 9 P3.5 send a High to low pulse as the Acknowledgement to processor that data is available on port so it enables the buffer iC to send data to processor so confusion is whether P3.5 is used as normal bit or the Timer T1 is used for sending Acknowledgement as P3.5 also works as Timer1 and Counter1 i am attaching DSO captured Images



Need Urgent Help
 

rajtech

Member level 2
Joined
Dec 25, 2007
Messages
45
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Activity points
1,569
Hi,

Please help to answer, how you handle the keyboard code,
when we press the keyboard key, it will generate make code,
when we release the keyboard key , it will generate break code.

key pressed: A.
make code: 1C.
key released : break code F0, 1C.
My question is how you read these three codes and assign the data.
Did you read only make code (1C) or read both make code and break code.
Thanks.
 

welove8051

Full Member level 6
Joined
Jul 16, 2009
Messages
357
Helped
51
Reputation
102
Reaction score
41
Trophy points
1,308
Location
india
Activity points
3,277
THIS PROGRAM WILL PRINT BETWEEN ZERO TO NINE(WHICH IS PRESENT IN ROW IN THE KEYBOARD) IN THE SECOND LINE OF LCD, IF ANY OF WHICH IS PRESSED.

Code:
RS 	EQU 	P3.3
RW 	EQU 	P3.4
EN 	EQU 	P3.5
DAT	EQU	P1
BUSY 	BIT 	P1.7 
KCLK	EQU	P3.0
KDAT	EQU	P3.1


ORG 0H
SJMP MAIN

ORG 30H
MAIN: 
	CALL INIT
	MOV DPTR,#MES1
	CALL MESSDISP
	MOV A,#0C0H     
        CALL COMNWRT
AGAIN:
	CALL KBDATA
	CJNE A,#0F0H,AGAIN
	CALL KBDATA
	CALL KBCOMPARE
	
JMP AGAIN

;===================================================================================================;
;------------------------------KBFUNCTIONS START--------------------------------------------------------;
;===================================================================================================;

KBDATA:	; PROTOCOL TO GET DATA FROM KEYBOARD
	MOV R3,#8
	MOV R7,#0
	KP1:MOV C,KCLK
	JC KP1
	K4:MOV C,KCLK
	JNC K4
	K5:MOV C,KCLK
	JC K5
	MOV C,KDAT
	MOV A,R7

	RRC A
	MOV R7,A
	K6:MOV C,KCLK
	JNC K6
	DJNZ R3,K5
	MOV R2,A
	MOV R4,#255
	DJNZ R4,$
RET

KBCOMPARE:	; SUBROUTINE TO CONVERT KEYBOARD DATA TO ASCII
	CJNE A,#16H,C1
	MOV A,#31H
	CALL DATAWRT
	RET
C1:	CJNE A,#1EH,C2
	MOV A,#32H
	CALL DATAWRT
	RET
C2:	CJNE A,#26H,C3
	MOV A,#33H
	CALL DATAWRT
	RET
C3:	CJNE A,#25H,C4
	MOV A,#34H
	CALL DATAWRT
	RET
C4:	CJNE A,#2EH,C5
	MOV A,#35H
	CALL DATAWRT
	RET
C5:	CJNE A,#36H,C6
	MOV A,#36H
	CALL DATAWRT
	RET
C6:	CJNE A,#3DH,C7
	MOV A,#37H
	CALL DATAWRT
	RET
C7:	CJNE A,#3EH,C8
	MOV A,#38H
	CALL DATAWRT
	RET
C8:	CJNE A,#46H,C9
	MOV A,#39H
	CALL DATAWRT
	RET
C9:	CJNE A,#45H,C10
	MOV A,#30H
	CALL DATAWRT
	RET
C10:	CJNE A,#76H,W1;ESC
	MOV A,#0F1H
	RET
W1:	MOV A,#0F6H;NO KEY
RET
GETKBDATA:
	CALL KBDATA
	CJNE A,#0F0H,GETKBDATA
	CALL KBDATA
	CALL KBCOMPARE
RET
INIT:	
	CLR RW
	MOV A,#38H      ;LCD 2 LINES
	CALL COMNWRT
	
        MOV A,#01H 	;CLEAR DISPLAY
	CALL COMNWRT
	
	MOV A,#0EH 	;DISPLAY ON CURSOR ON
	CALL COMNWRT
	
        MOV A,#6H 	;SHIFT CURSOR RIGHT
	CALL COMNWRT
	
	MOV A,#80H      ;SEND FIRST LINE ADDRESS
        CALL COMNWRT
        
       ;MOV A,#38H      
        ;CALL DATAWRT
RET
COMNWRT:
	CALL READY
       	MOV  DAT,A
       	CLR  RS
       	SETB EN
       	CLR  EN
RET

DATAWRT:
	CALL READY
       	MOV  DAT,A
       	SETB RS
       	SETB EN
       	CLR  EN
RET
       
READY:
	SETB BUSY
	SETB RW
	CLR RS
CH1:
	CLR EN
	NOP
	NOP
	SETB EN
	JB BUSY,CH1
	CLR RW
RET
     
MESSDISP:
D1:CLR A
MOVC A,@A+DPTR
CJNE A,#0FFH,CONT
RET
CONT:
CALL DATAWRT
INC DPTR
SJMP D1

MES1: DB  "WELOVE8051.COM",255
END
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top