Yup:
Its a pushbike dynamo lights system, the processor turns on the lights when the dynamo is turning fast enough by measuring the freq of the ac (by setting speedok flag).
Heres the section that measures the frequency and decides if the speed is ok, the section marked 'count' is what actually measures the freq, I use antirepeat flags to ensure that the incomming pulses are only counted once.
The first section minsp decides if the freq (contained in pulsecn) is high enough, the 'count' routine is run for a set time by using the speed register (250 calls = the correct gate freq), there is hysterysis on switch on and switch off speeds to avoid flicker.
;
;--------------------------------flash leds above min speed---------------------------
;
minsp decfsz speed,f
goto count
;
movlw d'250'
movwf speed ;every 0.25 seconds
;
btfss speedok
goto spdb
spdg movlw d'2'
goto on
;
spdb movlw d'3'
;
on subwf pulsecn,w
btfss status,c
goto spdbad
;
spdok bsf speedok ;speed above min so flag it
clrf pulsecn ;reset
retlw d'0'
;
spdbad bcf speedok ;speed to low forget t bomb out
clrf pulsecn
retlw d'0'
;
;--------------------------------------
;
count btfsc gpio,3 ;pulse from dynamo?
goto spdclr
;
btfsc antirepeat2 ;yes but anti repeat enabled bomb out
retlw d'0'
;
bsf antirepeat2 ;enable antirepeat
incf pulsecn,f ;else increment pulse count and bomb out
retlw d'0'
;
spdclr bcf antirepeat2
retlw d'0'
;
END ;directive 'end of program'