forked from ImperialCollegeLondon/MicroprocessorsLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeypad.asm
41 lines (31 loc) · 991 Bytes
/
keypad.asm
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
#include "p18f87k22.inc"
; code to operate the keypad
global KEYBOARD_VERT, KEYBOARD_HOR, DELAY
global count
acs0 udata_acs ; reserve data space in access ram
count res 1
keypad code 0x300 ; start keyboard code
KEYBOARD_VERT ; get vertical information of keypad
movlw 0x0F ; set half of port E to output and half to input
movwf TRISE
movlw 0xF0 ; send high to port E
movwf PORTE
call DELAY ; delay
movf PORTE, W ; read port E to W
return
KEYBOARD_HOR ; get horizontal information of keypad
movlw 0xF0 ; set other half of port E to output and half to input
movwf TRISE
movlw 0x0F ; send high to port E
movwf PORTE
call DELAY ; delay
movf PORTE, W ; read port E to W
return
DELAY ; delay for keyboards
movlw 0xAA
movwf count
DELAY_LOOP
DECFSZ count
bra DELAY_LOOP
return
end