Task-Specific Program Code
C-9
Program Examples
Example C–5. Testing and Using the Timer (timer.asm)
* File: timer.asm *
* Function: Timer test code *
* PRD=0x00ff,TDDR=f @ 50ns, gives an interrupt interval=205us *
* PRD=0xffff,TDDR=0 @ 50ns, gives an interrupt interval=3.27ms*
* Timer interval measurable on I/O 2,3 or xf pins *
.title ”Timer 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 #0000h,60h
out 60h, wsgr ; Set zero wait states
splk #0ffffh,ifr ; clear interrupts
splk #0004h,imr ; enable timer interrupt
splk #0e00ch, 60h ; configure bit I/O I03 and IO2 as outputs
out 60h, aspcr ; set the aspcr for the above
mar *,ar1
lar ar1,#rxbuf
splk #0004h,61h ; bit value to set I/O 2
splk #0008h,62h ; bit value to set I/O 3
out 61h,iosr ; set the bit 2 = high, 3= zero
splk #0000h, 63h
splk #00ffh, 64h
out 64h, prd ; set PRD=0x00ffh
out 63h, tim ; set TIM=0x0000
splk #0c2fh, 64h ; PSC, TDDR are zero, reload, restart
out 64h, tcr
clrc intm
clrc xf
wait: out 62h,iosr ; set io2=0
idle
clrc xf
b wait
timer: setc xf ; xf =1
in 68h,tcr ; Read tcr,prd, tim regs.
in 69h,prd
in 6ah,tim
out 61h,iosr ; set io2=1
clrc intm
ret
inpt1: ret ; Unused interrupt routines
inpt23: ret
codtx: ret
codrx: ret
uart: ret
.end ; Assembler module end directive –optional