get_column:
;calculate column number
mov
a,temp
;load temp
xor
a,mask
;test column number
snz
z
;
jmp
index
;no. test next column
ret
;yes. return (TBLP)
index:
;next column
inc
tblp
;(9)
;table index+1
set
c
;
rlc
mask
;shift mask left (LSB=1)
jmp
get_column
;repeat get_column key_in endp
delays proc
;delay subroutine
mov
a,0ffh
;load counter
mov
count1,a
;
d1:
sdz
count1
;count down count1
jmp
d1
ret
delays endp
org
300h
;display data table
dc
0fh,0eh,0dh,0ch ;key0, key1, key2, key3
dc
0bh,0ah,09h,08h ;key4, key5, key6, key7
dc
07h,06h,05h,04h ;key8, key9, keyA, keyB
dc
03h,02h,01h,00h ;keyC, keyD, keyE, keyF
end
Program description
Section (1) defines whether the port bits are defined as inputs or outputs.
The program enters a loop to determine which key is pressed. The code
works by first scanning line by line to determine if any key has been pressed
in that line. Because four keys are connected together in the same line, the
software must determine the exact key, which has been pressed. For
example in section (2) the first line is scanned to see if key 0~3 has been
pressed. If so this code then jumps out of this scanning loop to a subsection
(3), to determine which key connected to this line has been pressed. If not
the code moves on to look at the line containing keys 4-7 and so on. After
entering this code subsection, the code first stores the key value in a
temporary register as shown in section (4). There then follows a short time
delay (5), to take account of switch bounce and then code to determine when
the switch has been released (6). The code will not continue until the key
has been released. The next part is to determine which row has been
pressed (7). When jumping from row to row the corresponding table address
jumps by 4 bits each time (8). After determining the row, the pressed key
connected to this row has to be found. To do this the value in the accumu-
lator jumps in increments of one bit until the correct key is located, as
shown in (9). The correct key has thus been found by first looking at the
Chapter 15 Input/Output Applications
195
Содержание HT-IDE
Страница 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Страница 12: ...HT IDE User s Guide 2 ...
Страница 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Страница 24: ...HT IDE User s Guide 14 ...
Страница 70: ...HT IDE User s Guide 60 ...
Страница 76: ...HT IDE User s Guide 66 ...
Страница 92: ...HT IDE User s Guide 82 ...
Страница 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Страница 94: ...HT IDE User s Guide 84 ...
Страница 148: ...HT IDE User s Guide 138 ...
Страница 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Страница 154: ...HT IDE User s Guide 144 ...
Страница 192: ...HT IDE User s Guide 182 ...
Страница 194: ...HT IDE User s Guide 184 ...
Страница 218: ...HT IDE User s Guide 208 ...
Страница 235: ...P a r t V Appendix Part V Appendix 225 ...
Страница 236: ...HT IDE User s Guide 226 ...
Страница 250: ...HT IDE User s Guide 240 ...