SOFTWARE EXAMPLES
7 - 22
DSP56002 TIMER AND EVENT COUNTER
MOTOROLA
ORG
P:$3C
;this is timer interrupt vector address
JSR
MEASURE
;long interrupt to measure period
....
ORG P:MAIN_BODY
.....
MOVE #0,X:TEMP
;clear temporary storage
MOVE #PERIOD,r0
;r0 points to start of table
MOVE #$FF,M0
;modulo 100 to wrap around on end of table
MOVEP #$00002A,X:TCSR ;enable timer interrupts, mode 5
BSET
#IPL,X:IPR
;enable IPL for timer
ANDI
#$CF,MR
;remove interrupt masking in status register
BSET
#TE,X:TCSR
;timer enable
......
; do other tasks
.....
measure
MOVEP X:TCR,A
;read new counter value
MOVE X:TEMP,X0
;retrieve former read value (initially zero)
SUB
X0,A
A,X:TEMP
;compute delta (i.e. new -old) and store the
;new read value in temp
MOVE A,X:(R0)+
;store period value in table
RTI
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..