#include "c:\miniide\hcs12.inc" org $1000 paov_cnt ds.b 1 ; use to keep track of the PACNT overflow count pulse_width ds.b 3 ; hold the signal frequency org $1500 movw #paov_isr,UserPAccOvf ; set up PAOV interrupt vector ldd #0 std PACNT ; let PACNT count up from 0 clr paov_cnt ; initialize PACNT overflow count to 0 movb #$0,TSCR2 ; set TCNT timer prescaler to 1 ; configure PA function: enable PA, select gated time accumulator mode, high level ; of PAI signal enables PACNT counter, enable PAOV interrupt movb #$72,PACTL bclr DDRT,$80 ; configure PAI pin for input cli ; enable PAOV interrupt brclr PAFLG,PAIF,* ; wait for the arrival of the falling edge of PAI movb #0,PACTL ; disable PA function sei ; disable interrupt ldd PACNT std pulse_width+1 ldaa paov_cnt staa pulse_width swi paov_isr movb #PAOVF,PAFLG ; clear the PAOVF flag inc paov_cnt ; increment PACNT overflow count by 1 end