


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















Revised: Aug 1, 2003
Revised: Aug 1, 2003
Revised: Aug 1, 2003
Revised: Aug 1, 2003
Revised: Aug 1, 2003
-^ Input Capture - measure signal parameters–^ system description–^ register description–^ programming•^ General concept–^ capture value of free running counter when user-specified eventoccurs• rising edge, falling edge, any edge–^ calculate elapsed time between key events–^ EX] pulse length, pg 257-
Revised: Aug 1, 2003 Programming - Input Capture EX] Measure the period of a periodic signalconnected to input capture channel 2– Assume MCLK is 8 MHz– Set prescaler to divide by 4– Clock frequency to frc is therefore 2 MHz– Period: 0.
Revised: Aug 1, 2003
Revised: Aug 1, 2003
main-initializeTIMERINIT MEAS_PER .area test_1(abs).ORG^ $^
;User RAM at $ edge_1 FDB^
;reserve word for variable period FDB^
;reserve word for variable _main::BSR TIMERINIT
;timer initialization subr BSR MEAS_PER
;measure period DONE:^ BSA DONE
;Branch to self
Revised: Aug 1, 2003
;-----------------------------------------------;Subroutine TIMERINIT: Initialize timer for IC2;;-----------------------------------------------TIMERINIT: CLR
;disable interrupts LDX^ #REG_BASE
;load register base to X LDAA^ #TMSK2_IN
;load TMSK2 using index addr STAA^ TMSK2,X
;disable ovf, prescale= LDAA^ #TCTL4_IN
;conf IC2 for rising edge STAA^ TCTL4,X
;select ch 2 for IC STAA^ TIOS,X
;conf IC2 for rising edge STAA^ TSCR_IN,X
; enable timer, standard flag clr RTS^
;Return from subroutine
Revised: Aug 1, 2003
-^ generate precision signals based on key events–^ active low or high pulse–^ repetitive signal ofdesired frequency and duty cycle–^ pulse width modulation•^ key events
Revised: Aug 1, 2003
Revised: Aug 1, 2003
Revised: Aug 1, 2003
;----------------------------------------;MAIN PROGRAM: This program generates a;1000 Hz square wave with a 50% duty cycle;on output compare channel 2.;----------------------------------------TMSK1^ =^
;declare locations of registers TMSK2^ =^
;declare locations of registers TCTL2^ =^
;declare locations of registers TIOS^ =^
;declare locations of registers TC2H^ =^
;declare locations of registers TSCR^ =^
;declare locations of registers TFLG1^ =^
;declare locations of registers TMSK2_IN^ =^
;disable TOI, prescale= TCTL2_IN^ =^
;initialize OC2 toggle TIOS_IN^ =^
;select ch2 for OC TSCR_IN^ =^
;enable timer, normal flag clr