SOFTWARE EXAMPLES
MOTOROLA
DSP56002 TIMER AND EVENT COUNTER
7 - 21
BSET
#DO,X:TCSR
;set TIO to signal end of task
BCLR #DO,X:TCSR
;clear
TIO
RTI
;return to main program
7.8.4
Pulse Width Measurement Mode (Timer Mode 4)
The following program illustrates the usage of the timer module for input pulse width
measurement. The width is measured in this example for the low active period of the
input pulse on the TIO pin and is stored in a table (in multiples of the chip operating clock
divided by 2).
ORG
X:$100
;define buffer in X memory internal
pulse_width DS
$100
;measure up to 256 pulses
ORG
P:$3C
;this is timer interrupt vector address
MOVEP X:TCR,X:(r0)+
;store width value in table
NOP
;second word of the short interrupt
....
ORG P:MAIN_BODY
.....
MOVE #PULSE_WIDTH,r0 ;r0 points to start of table
MOVE #$FF,M0
;modulo 100 to wrap around on end of table
MOVEP #$000026,X:TCSR ;enable timer interrupts, mode 4 and set INV
;to measure the low active pulse
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
.....
7.8.5
Period Measurement Mode (Timer Mode 5)
The following program illustrates the usage of the timer module for input period measure-
ment. The period is measured in this example between 0 to 1 transitions of the input signal
on TIO and is stored in a table (in multiples of the chip operating clock divided by 2).
ORG
X:$100
;define buffer in X memory internal
period
DS
$100
;measure up to 256 pulses
temp
DS
$1
;temporary storage
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
.
..
Содержание DSP56002
Страница 380: ......
Страница 382: ......
Страница 390: ...Freescale Semiconductor I Freescale Semiconductor Inc For More Information On This Product Go to www freescale com nc...