#include "c:\miniide\hcs12.inc" org $1000 edge_1st rmb 2 ; memory to hold the first edge period rmb 2 ; memory to store the period org $1500 movb #$90,tscr1 ; enable timer counter and enable fast timer flags clear bclr tios,IOS0 ; enable input capture 0 movb #$06,tscr2 ; disable TCNT overflow interrupt, set prescale factor to 64 movb #$01,tctl4 ; choose to capture the rising edge of PT0 pin movb #C0F,tflg1 ; clear the C0F flag wait1 brclr tflg1,C0F,wait1 ; wait for the arrival of the first rising edge ldd tc0 ; save the first edge and clear the C0F flag std edge_1st wait2 brclr tflg1,C0F,wait2 ; wait for the arrival of the second edge ldd tc0 subd edge_1st std period swi end