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.

[General] Interfacing LCD and keypad with pic16f877 using mplab assmbley

Status
Not open for further replies.

Ahmad Al-zghoul

Newbie level 3
Newbie level 3
Joined
Dec 19, 2014
Messages
4
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Visit site
Activity points
43
i need help to Interfacing LCD and keypad with pic16f877 using mplab assmbley code

i need help to Interfacing LCD and keypad with pic16f877 using mplab assmbley code
 
Last edited:

Because the programming that we learn in our university language is assembly this project and asked me, but I can not find a solution
 

I found this code and when you do not work simulated Can you help me?




Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; KEYPAD.ASM MPB Ver 1.0 28-8-05
;
; Reads keypad and shows digit on display
; Design file KEYPAD.DSN
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCESSOR 16F877
PCL EQU 002 ; Program Counter
PORTC EQU 007 ; 7-Segment display
PORTD EQU 008 ; 3x4 keypad
TRISC EQU 087 ; Data direction
TRISD EQU 088 ; registers
Key EQU 020 ; Count of keys
; Initialise ports.........................................
BANKSEL TRISC ; Display
CLRW ; all outputs
MOVWF TRISC ;
MOVLW B'00000111' ; Keypad
MOVWF TRISD ; bidirectional
BANKSEL PORTC ; Display off
CLRF PORTC ; initially
GOTO main ; jump to main
; Check a row of keys .....................................
row INCF Key ; Count first key
BTFSS PORTD,0 ; Check key
GOTO found ; and quit if on
INCF Key ; and repeat
BTFSS PORTD,1 ; for second
GOTO found ; key
INCF Key ; and repeat
BTFSS PORTD,2 ; for third
GOTO found ; key
GOTO next ; go for next row
; Scan the keypad..........................................
scan CLRF Key ; Zero key count
BSF 3,0 ; Set Carry Flag
BCF PORTD,4 ; Select first row
newrow GOTO row ; check row
next BSF PORTD,3 ; Set fill bit
RLF PORTD ; Select next row
BTFSC 3,0 ; 0 into carry flag?
GOTO newrow ; if not, next row
GOTO scan ; if so, start again
found RETURN ; quit with key count
; Display code table.......................................
table MOVF Key,W ; Get key count
ADDWF PCL ; and calculate jump
NOP ; into table
RETLW B'00001100' ; Code for '1'
RETLW B'10110110' ; Code for '2'
RETLW B'10011110' ; Code for '3'
RETLW B'11001100' ; Code for '4'
RETLW B'11011010' ; Code for '5'
RETLW B'11111010' ; Code for '6'
RETLW B'00001110' ; Code for '7'
RETLW B'11111110' ; Code for '8'
RETLW B'11001110' ; Code for '9'
RETLW B'10010010' ; Code for '*'
RETLW B'01111110' ; Code for '0'
RETLW B'11101100' ; Code for '#'
; Output display code......................................
show CALL table ; Get display code
MOVWF PORTC ; and show it
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read keypad & display....
main MOVLW 0FF ; Set all outputs
MOVWF PORTD ; to keypad high
CALL scan ; Get key number
CALL show ; and dsiplay it
GOTO main ; and repeat
END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 
Last edited by a moderator:
You might try the PicList.org site, they specialize in assembly routines and offer a fairly extensive library of routines for almost any occasion.

For Example:






BigDog
 
i found this can you help me to make the circuit of this in Proteus 8 Professional
**broken link removed**

When the simulation so happens

10864482_731005476989780_2134874720_o.jpg

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; KEYPAD.ASM MPB Ver 1.0 28-8-05
;
; Reads keypad and shows digit on display
; Design file KEYPAD.DSN
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PROCESSOR 16F877
PCL EQU 002 ; Program Counter
PORTC EQU 007 ; 7-Segment display
PORTD EQU 008 ; 3x4 keypad
TRISC EQU 087 ; Data direction
TRISD EQU 088 ; registers
Key EQU 020 ; Count of keys
; Initialise ports.........................................
BANKSEL TRISC ; Display
CLRW ; all outputs
MOVWF TRISC ;
MOVLW B'00000111' ; Keypad
MOVWF TRISD ; bidirectional
BANKSEL PORTC ; Display off
CLRF PORTC ; initially
GOTO main ; jump to main
; Check a row of keys .....................................
row INCF Key ; Count first key
BTFSS PORTD,0 ; Check key
GOTO found ; and quit if on
INCF Key ; and repeat
BTFSS PORTD,1 ; for second
GOTO found ; key
INCF Key ; and repeat
BTFSS PORTD,2 ; for third
GOTO found ; key
GOTO next ; go for next row
; Scan the keypad..........................................
scan CLRF Key ; Zero key count
BSF 3,0 ; Set Carry Flag
BCF PORTD,4 ; Select first row
newrow GOTO row ; check row
next BSF PORTD,3 ; Set fill bit
RLF PORTD ; Select next row
BTFSC 3,0 ; 0 into carry flag?
GOTO newrow ; if not, next row
GOTO scan ; if so, start again
found RETURN ; quit with key count
; Display code table.......................................
table MOVF Key,W ; Get key count
ADDWF PCL ; and calculate jump
NOP ; into table
RETLW B'00001100' ; Code for '1'
RETLW B'10110110' ; Code for '2'
RETLW B'10011110' ; Code for '3'
RETLW B'11001100' ; Code for '4'
RETLW B'11011010' ; Code for '5'
RETLW B'11111010' ; Code for '6'
RETLW B'00001110' ; Code for '7'
RETLW B'11111110' ; Code for '8'
RETLW B'11001110' ; Code for '9'
RETLW B'10010010' ; Code for '*'
RETLW B'01111110' ; Code for '0'
RETLW B'11101100' ; Code for '#'
; Output display code......................................
show CALL table ; Get display code
MOVWF PORTC ; and show it
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read keypad & display....
main MOVLW 0FF ; Set all outputs
MOVWF PORTD ; to keypad high
CALL scan ; Get key number
CALL show ; and dsiplay it
GOTO main ; and repeat
END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
To interface LCD and Keypad to Microcontroller in asm all you need to do is to scan the keypad every 10ms and and Display result on LCD

Using PortD as input for scanning Keypad
Scanning First row techniques
Code:
     BSF PortD,0
     BCF PortD,1
     BCF PortD,2

Scanning First Column in Row 1
Code:
  BtFss PortD,3
  Goto  Col_2
  Call Delay20ms
  Movlw  '1'
  Movwf Key_disp
  Return

Do same for second column and so on
 
Last edited by a moderator:
i want to know where to add the program for scanning in the assembly . i would be grateful if you can post the full assembly code
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top