org
08h
;timer/event 0 interrupt subroutine
cpl
pb
;(6)
;generate square wave
reti
;end timer0 ISR
org
0ch
;timer/event 1 interrupt subroutine
reti
;for safeguard
start:
;
clr
intc
;initialize registers
clr
tmr0c
;to guarantee performance
clr
tmr0h
;(interrupts)
clr
tmr0l
;
clr
tmr1c
;
clr
tmr1
;
set
pac
;(ports)
set
pbc
;(input mode)
set
pcc
;
set
pdc
;
main:
set
pac
;(1)
;set port A to input port
clr
pbc
;set port B to output port
clr
pb
;
keyloop:
;(2)
;
mov
a,pa
;test any input
cpl
acc
;
sz
acc
;if any?
call
whichkey
;yes. find out which key
jmp
keyloop
;no. repeat from keyloop
whichkey proc
;(3)
;find out which key
mov
temp,a
;hold Acc content
mov
a,0
;zero table index
mov
tblp,a
;
clr
c
;c=0 (check each bit(key) by carry flag)
keynext:
;
rrc
temp
;shift right through carry flag
sz
status.0
;if carry? (some key was pressed)
jmp
timerset
;yes. output sound
inc
tblp
;(4)
;no. table index point to next
inc
tblp
;(2 bytes/key)
jmp
keynext
;check next bit (key)
timerset:
;set timer to generate sound
mov
a,5
;enable timer0
mov
intc,a
;
mov
a,80h
;set timer0 mode (internal clock)
mov
tmr0c,a
;
tabrdl sound
;(5)
;load freq.
mov
a,sound
;(low byte)
mov
tmr0l,a
;
inc
tblp
;
tabrdl sound
;(6)
;(high byte)
mov
a,sound
;
Chapter 16 Interrupt and timer applications
211
Содержание 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 ...