1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| begin
call scan_keypad ;if no input pressed, w= 16, what_button=16
call keypad_data ;if w=16, return w=0
xorlw 00H ;if w=0 , status Z become 1
btfsc status,z ;if Z=1, no button pressed keep looping
goto begin
scan_keypad ;subroutine
movf what_button,w
bsf PORTD,0 ;scan first column of keys
btfsc PORTC,2 ;has the * key been pressed? if yes then
movlw d'14' ; copy *(14) into w , not then skip
btfsc PORTC,3 ;has the 7 key been pressed? if yes then
movlw d'07' ; copy 7 into w , not then skip
btfsc PORTC,4 ;has the 4 key been pressed? if yes then
movlw d'04' ; copy 4 into w , not then skip
btfsc PORTC,5 ;has the 1 key been pressed? if yes then
movlw d'01' ; copy 1 into w , not then skip
bcf PORTD,0 ;finished scanning first column
...
if no keypad is pressed movlw d'16'
movf what_button,w
return |