Stereo System User Manual
MOTOROLA 45
6.7.4 Pulse width measurement mode (mode 4)
The following program illustrates the use of the timer module for input pulse width mea-
surement. The width is measured in this example for the low active period of the input
pulse on the TIO1 pin and is stored in a table (in multiples of the chip operating clock di-
vided by 2).
org x:$100 ; define buffer in X memory internal
pulse_width ds $100 ; measure up to 256 pulses
org p:$16
; this is timer1 interrupt vector address
movep x:TCR1,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 #$70000000,x:TCSR1 ; enable timer interrupts, mode 4 and set INV
; to measure the low active pulse
bset #26,x:IPR ; enable IPL for timer 1
andi #$cf,mr ; remove interrupt masking in status register
bset #31,x:TCSR1 ; timer enable
......
; do other tasks
.....