Total members 11895 |It is currently Thu Dec 26, 2024 1:20 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





SCANNING THE KEYPAD, input from keypad PIC Assembly
Code:
TITLE "SCANNING THE KEYPAD"
list 16f877
include <p16f877.inc>
BANK0 macro
bcf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK1 macro
bsf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK2 macro
bcf STATUS
,RP0
bsf STATUS
,RP1
endm

BANK3 macro
bsf STATUS
,RP0
bsf STATUS
,RP1
endm
;*
DELAY_TIME EQU 0x20
KEYDATA EQU 0x21
TEMP EQU 0x22
;****
ORG 0
NOP 
GOTO START 
;***
MAIN ROUTINE 
 ORG 0x20
 START CALL INIT 
;INITIALISE PORTS
AGAIN MOVLW 1 
;SET ROW 1 HIGH
MOVWF PORTD 
;AND OUTPUT
BTFSS PORTD
,;TEST COLUMN 1 No 3
GOTO SIX 
;IF NOT 3, TRY 6
MOVLW 3 
;ELSE STORE 3
MOVWF KEYDATA 
;IN KEyDATA
GOTO LAST 
;AND FINISH
SIX BTFSS PORTD
,;TEST COLUMN 1 No €
GOTO NINE 
;IF NOT 6, TRY 9
MOVLW 6 
;ELSE STORE 6
MOVWF KEYDATA 
;IN KEyDATA
GOTO LAST 
:AND FINISH
NINE BTFSS PORTD
,;TEST COLUMN 1 No 5
GOTO NUM 
;IF NOT 5, TRY NUM *
MOVLW 9 ;ELSE STORE 9
MOVWF KEYDATA 
;IN KEyDATA
GOTO LAST 
;AND FINISH
NUM BTFSS PORTD
,;TEST cOLUMN 1 NUM *
GOTO COL2 ;IF NOT NUM, TRY COL 2
MOVLW 0FFH 
;ELSE SToRE FFH
MOVWF KEYDATA 
;IN KEyDATA
GOTO LAST 
;AND FINISH
COL2 MOVLW 2 
;SET ROW 2 HIGH
MOVWF PORTD 
;AND OUTPUT
BTFSS PORTD
,;TEST COLUMN 2 No 2
GOTO FIVE 
;IF NOT 2, TRY 5
MOVLW 2 
;ELSE STORE 2
MOVWF KEYDATA 
;IN KEyDATA
GOTO LAST 
;AND FINISH
FIVE BTFSS PORTD
,;TEST COLUMN 2 No 5

GOTO EIGHT 
;IF NOT 5, TRY
MOVLW 5 ;ELSE SToRE 5
MOVWF KEYDATA 
;IN KEYDATA
GOTO LAST 
;AND FINISH

EIGHT BTFSS PORTD
,;TEST COLJMN 2 No 8
GOTO NONE 
;IF NOT 8, TRY 0
MOVLW 8 
;EISE STORE 8
MOVWF KEYDATA 
;IN KEYDATA
GOTO LAST 
;AND FINISH

NONE BTFSS PORTD
,;TEST COIIJMN 2 No 0
GOTO COL3 
;IF NoT ZERo, TRy CoL 3
MOVLW 0 
;ELSE SToRE 0
MOVWF KEYDATA 
;IN KEYDATA
GOTO LAST 
;AND FINISH

C0L3 MOVLW 4 
;SET RoW 3 HIGH
MOVWF PORTD 
;AND OUTPUT
BTFSS PORTD
,;TEST cOLJw’iN 3 No 1
GOTO FOUR 
;IF NoT 1, TRy 4
MOVLW 1 
;ELSE SToRE 1
MOVWF KEYDATA 
;IN KEYDATA
GOTO LAST 
; AND FINISH

FOUR BTFSS PORTD
,6
GOTO SEVEN
MOVLW 4
MOVWF KEYDATA
GOTO LAST

SEVEN BTFSS PORTD
,;TEST COLJ 3 No 7
GOTO STAR 
;IF NOT 7, TRY
MOVLW 7 ;ELSE SToRE 7
MOVWF KEYDATA 
;|IN KEYDATA
GOTO LAST 
;AND FINISH

STAR BTFSS PORTD
,;TEST COLJMN 3 ‘
GOTO LOOP 
;IF NOT a, TRY REPEAT
MOVLW 0FFH 
;ELSE SToRE FF11
MOVWF KEYDATA 
;IN KEYDATA
GOTO LAST 
;AND FINISH


LAST CALL DELAY 
;DEBoUNDz KEYPAD
LOOP MOVF PORTD
,;READ PORT
ANDLW 0F0H 
;MASK OL5
BTFSS STATUS
,;AND WAIT TILL No PRESSED
GOTO LOOP
GOTO AGAIN 
;Do AGAIN


PORT INTIAlISATION
INIT BANK1 
;SET To BANK 1
MOVLW 0xF0 
;SET BITS 0-AS oUT4-AS IN
MOVWF TRISD
BANK0 
;BACK To BANK 0
RETURN

DELAy RotJTIN
DELAY MOVWF TEMP 
;SAvE W
      MOVLW 0xFF
      MOVWF DELAY_TIME
      
WAIT INCFSZ DELAY_TIME
     GOTO WAIT
     MOVF TEMP
,W
     
RETURN 
     
END




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : SCANNING THE KEYPAD, input from keypad PIC Assembly
 PIC Assembly For Loop Example     -  
 multiply two numbers in PIC assembly     -  
 macro usage PIC assembly     -  
 playfair cipher assembly code     -  
 Control Directives usage PIC assembly     -  
 TEMPERATURE AND HEAT CONTROL Assembly     -  
 Elements of Assembly Language Instruction     -  
 MULTIPLEXING Seven SEGMENT DECODER Assembly     -  
 getting a full line input     -  
 input suggestion using Javascript     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com