Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

[SOLVED] Interfacing LCD with Keyboard asembler

Status
Not open for further replies.

Maxeyas

Junior Member level 3
Joined
Apr 4, 2016
Messages
28
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Activity points
278
Hello edaboard. I'm Max,

I'm trying to display on LCD pressed key & there is serval issues:

1) Before pressing any key when reseting, it will show the address 0h as pressed (It shows '**' twice on the LCD when resetting).
2) Each time i press a key it shows it twice (There is 2 capacitors, one connected to KBM "104->10pF" & second to OSC (not sure about the value, probably the same)).

Those issues should be fixed first.

I want afterwards to check if First line is full of pressed keys & shift to second line if it is. How I check & apply?

#0C0h - The 74hc138 address which activates the LCD.
#20h - The 74hc138 address which activates Keyboard.

Explaination:
Using INT0 in P3.2 to determinate if key pressed. If the signal going low the interrupt is initiated.
Which is why i'm setting IT0 '1' & IE as 10000001.

* No I cannot replace any device or capacitor or resistor. Only if its 100% neccesery which means broken.
I wonder if needed schematics & datasheet. Its just a software issues. Help would be appreciated.

Here is the full code:
Code:
; Defines
RS EQU P1.0 ;Register Select
EN EQU P1.1 ;Enable Pin

org 0h
ljmp Main
org 3h
mov P0, #0FFh
mov P2, #20h
mov A, P0
anl A, #0Fh
ljmp ScanKeys
KeyPressed:
lcall SendData
reti

Main:
lcall InitLCD
mov IE,#10000001B // ES=1,EX0=1
setb IT0
sjmp $
	
InitLCD:
;50ms Delay before initialization
lcall LongDelay

;Function Set - 2 lines 8bit
mov A, #38h
lcall SendCommand

;Display Control - display on, cursor off
mov A, #0Ch
lcall SendCommand

;Entry mode set - auto-increment cursor and disable shift mode
mov A, #06h
lcall SendCommand

;Display Clear - clearing the screen and setting cursor home
lcall ClearDisplay
ret

SecondLine:
mov A, #0C0h
lcall SendCommand
ret

ClearDisplay:
mov A, #01h
lcall SendCommand
ret

SendCommand:
mov P2, #0C0h
clr RS ; Setting 0 in RS (0=commands,1=data)
mov P0, A
setb EN ; Setting 1 in EN (pulse)
clr EN ; Setting 0 in EN (send pulse)
lcall Delay
ret

SendData:
mov P2, #0C0h ;
setb RS ; Setting 1 in RS (0=commands,1=data)
mov P0, A
setb EN ; Setting 1 in EN (pulse)
clr EN ; Setting 0 in EN (send pulse)
lcall Delay
ret

Delay: ; 100x20 = 2000us = 2 ms
mov R7, #100
D3: mov R6, #20
djnz R6,$
djnz R7,D3
ret

LongDelay: ; 250x200 = 50000us = 50ms
mov R7, #250
D4: mov R6, #200
djnz R6,$
djnz R7,D4
ret

ScanKeys:
cjne A,#0,KeyCheck1
mov A, #'*'
lcall SendData
ljmp KeyPressed
KeyCheck1:
cjne A,#1,KeyCheck2
mov A, #'7'
lcall SendData
ljmp KeyPressed
KeyCheck2:
cjne A,#2,KeyCheck3
mov A, #'4'
lcall SendData
ljmp KeyPressed
KeyCheck3:
cjne A,#3,KeyCheck4
mov A, #'1'
lcall SendData
ljmp KeyPressed
KeyCheck4:
cjne A,#4,KeyCheck5
mov A, #0
lcall SendData
ljmp KeyPressed
KeyCheck5:
cjne A,#5,KeyCheck6
mov A, #'8'
lcall SendData
ljmp KeyPressed
KeyCheck6:
cjne A,#6,KeyCheck7
mov A, #'5'
lcall SendData
ljmp KeyPressed
KeyCheck7:
cjne A,#7,KeyCheck8
mov A, #'2'
lcall SendData
ljmp KeyPressed
KeyCheck8:
cjne A,#8,KeyCheck9
;mov A, #'#' Clearing LCD
lcall ClearDisplay
ljmp KeyPressed
KeyCheck9:
cjne A,#9,KeyCheck10
mov A, #'9'
lcall SendData
ljmp KeyPressed
KeyCheck10:
cjne A,#0Ah,KeyCheck11
mov A, #'6'
lcall SendData
ljmp KeyPressed
KeyCheck11:
cjne A,#0Bh,KeyCheck12
mov A, #'3'
lcall SendData
ljmp KeyPressed
KeyCheck12:
cjne A,#0Ch,KeyCheck13
mov A, #'D'
lcall SendData
ljmp KeyPressed
KeyCheck13:
cjne A,#0Dh,KeyCheck14
mov A, #'C'
lcall SendData
ljmp KeyPressed
KeyCheck14:
cjne A,#0Eh,KeyCheck15
mov A, #'B'
lcall SendData
ljmp KeyPressed
KeyCheck15:
mov A, #'A'
lcall SendData
ljmp KeyPressed

end
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top