'Serial IF for Blacat Rad software '16F676 'G8RPI cmcon = 7 'for pic10F206 ansel = 0 'for 16F676 input porta.4 output porta.2 't1con = 1 'set timer 1 on, internal clock, bit0 =1 't1con = 3 'set timer 1 on, external clock, bit0 =1, bit1 =1 't1con = 17 'set timer 1 on, internal clock, prescale 2 bit0=1 bit4=1 't1con = 33 'set timer 1 on, internal clock, prescale 4 bit0=1 bit4=0 bit5=1 ct0 var word 'total number of counts t1hi var ct0.byte1 'high byte of timer 1 t1lo var ct0.byte0 'low byte of timer1 ovf var bit 'overflow flag bit ctime var word 'counting time ctime = 952 'CPS Main: if porta.4 = 0 then 'test state of pin 3 ctime = 57120 'CPM (952x60) else ctime = 952 'CPS endif Serout porta.0,6,[#ctime ,13 ,10] porta.2 =1 'turn led on t1con = 7 'set timer 1 on, external clock, non sync = bit0 =1, bit1 =1, bit2 =1 tmr1h = 0 'clear timer 1 high byte tmr1l = 0 'clear timer 1 low byte pir1 = 0 'clear overflow flag pause ctime 'wait t1con = 0 'stop timer 1 , bit0 =0 porta.2 =0 'turn led off t1lo = tmr1l t1hi = tmr1h ovf = pir1 if ovf = 1 then Serout porta.0,6,["OVER-RANGE" ,13 ,10] else Serout porta.0,6,["tmr1lo ", #t1lo, ", tmr1hi ", #t1hi, ", Total ", #ct0 ,13 ,10] endif goto main stop 'loop forever to keep watchdog reset end