Task-Specific Program Code
C-12
Example C–8. Testing and Using Interrupts INT2 and INT3 (intr23.asm)
* File:
intr23.asm
*
* Function:
Interrupt test code
*
* Interrupt on INT2 or INT3 will toggle IO3 and IO2 bits
*
* and icr value copied in the Buffer @300
*
.title ” Interrupt 2/3 Test”
; Title
.copy
”init.h”
; Variable and register declaration
.copy
”vector.h”
; Vector label declaration
.text
start:
clrc
CNF
; Map block B0 to data memory
ldp #0h
; set DP=0
setc
INTM
; Disable all interrupts
splk
#0ffffh, ifr
; clear interrupts
splk
#0002h, imr
; Enable int1 interrupts
splk
#0003h, 60h
out
60h, icr
; Enable Int2 and 3 in ICR
splk
#0000h, 60h
out
60h, wsgr
; Set zero wait states
splk
#0e00ch, 60h
; configure the I03 and IO2 as outputs
out
60h, aspcr
; set the aspcr for the above
mar
*, ar1
; ARP=ar1
lar
ar1, #rxbuf
lar
ar0, #size
; set counter limit
splk
#0004h, 61h
; set bit I/O 2
splk
#0008h, 62h
; set bit I/O 3
splk
#0063h, 63h
; set tx data
clrc
intm
clrc
xf
wait:
out
61h, iosr
; toggle I/O 2
idle
clrc
xf
; toggle xf bit
b
wait
inpt23:
in
65h, icr
; Read icr
in
*+, icr
; Capture icr in buffer @300
mar
*,ar0
banz
skip, ar1
lar
ar1, #rxbuf
lar
ar0, #size
skip:
out
62h, iosr
; toggle IO2/3
setc
xf
; toggle xf
out
65h, icr
; clear interrupt 2/3 flag bit
clrc
intm
ret
timer:
ret
inpt1:
ret
uart:
ret
codtx:
ret
codrx:
ret
.end
; Assembler module end directive
; –optional