#include "c:\miniide\hcs12.inc" org $1000 oc_cnt rmb 1 paov_cnt rmb 2 ; use to keep track PACNT overflow count frequency rmb 4 ; hold the signal frequency org $1500 lds #$1500 movw #paov_isr,UserPAccOvf ; set up PAOV interrupt vector ldaa #50 staa oc_cnt ; prepare to perform 50 OC0 actions ldd #0 std PACNT ; let PACNT count up from 0 std paov_cnt ; initialize PACNT overflow count to 0 std frequency ; initialize frequency to 0 std frequency+2 ; " movb #$90,TSCR1 ; enable TCNT and fast timer flag clear bset TIOS,OC0 ; select OC0 function movb #$03,TSCR2 ; set prescaler to TCNT to 8 bclr DDRT,$80 ; configure PT7 for input ; configure PA function: enable PA, select event counting mode, rising edge ; of PAI signal increments the PACNT counter, enable PAOV interrupt movb #$52,PACTL cli ; enable PAOV interrupt ldd TCNT sec_loop addd #60000 std TC0 brclr TFLG1,C0F,* ; wait for 20 ms here ldd TC0 dec oc_cnt bne sec_loop movb #0,PACTL ; disable PA function sei ; disable interrupt ldd PACNT std frequency+2 ldd paov_cnt std frequency swi paov_isr movb #PAOVF,PAFLG ; clear the PAOVF flag ldx paov_cnt ; increment PACNT overflow inx ; count by 1 stx paov_cnt ; " end