
CTM
REFERENCE
MOTOROLA
8-21
DOUBLE ACTION SUBMODULE (DASM)
For More Information On This Product,
Go to: www.freescale.com
8
8.7.2
IPM mode example
****************************************************************************
*
*
DASM_IPM (for CPU16 based devices)
*
*
Demonstration of the DASM CTM sub-module operating in IPM mode.
*
The DASM is configured to measure periods between input falling
*
edges. An interrupt is generated after each measured period.
*
The interrupt routine <ipm1> calculates the period result after
*
each interrupt.
*
*
Timings assume 16.777MHz system clock
*
****************************************************************************
* Set up the bus interface unit sub-module, BIUSM
ldd
#$0C01
std
BIUMCR
; CTM not stopped, ignore FREEZE,
; vector base =$4x, IARB2-0=4, BUS B displayed
* Set up the counter prescaler module, CPSM
ldd
#$0008
std
CPCR
; Set PRUN to start prescaler and set
; PCLK dividers to /2 /4 /8 /16 /32 and /64
* Set up the free running counter module, FCSM
ldd
#$0905
std
fcsm25sic
; No interrupts, arb3=1, timebase B driven
; Clock using PCLK6 (/64 clock, 3.8147
μ
s)
ldd
std
#$0900
dasm10sic
; MODE = %0000 = DIS
; Disable DASM module before re-configuring
* Ensure that CPU will respond to a level 1 interrupt
andp
#$FF1F
; AND CCR with $FF1F to clear interrupt mask
* DASM IPM mode initialization
ldd
#$1912
; MODE = %0010
; EDPOL = 1
; BSL = 1
; IARB3 = 1
; IL = %001
Select IPM mode
Measure between -ve edges
Use time base bus B
Lowest priority interrupt
std
bra
dasm10sic
loop
loop
; Hang here (until interrupt)
***********************************************************************
*
*
IPM1 interrupt routine.
*
The interrupt vector for the DASM module should
*
contain the entry address <ipm1>
*
***********************************************************************
ipm1
bclr
ldd
lde
sde
rti
dasm10sic,#$80
dasm10b
dasm10a
; Clear DASM FLAG
; Get the period start time
; ..and the period end time
; Subtract to get the period width in e
; Return from interrupt
result
F
.
Freescale Semiconductor, Inc.