Hi Nick,
Ah, ok, it's the I've got a hammer now everything looks like a nail kind of thing ;-)
Well, as with most things there are more than one way to skin a cat. What I'd do is probably something like this (for 12F683 but not tested):
Code:
' CMCON, ANSEL, TRIS, whatever not shown here!
oldCount VAR BYTE
LED VAR GPIO.0
oldCount = 0 'Clear count
LED = 0 ' Turn off LED
' Set TMR0 up as a counter, signal fed into T0CKI pin
OPTION_REG.5 = 1
Main:
If TMR0 <> oldCnt THEN ' There has been pulses since last time we checked
LED = 1
ELSE
LED = 0
ENDIF
oldCnt = TMR0 ' Store current count
' Now wait a bit to allow any new pulses to "tickle" the counter.
' Shortest PauseUs time @8Mhz is 12us.
' If faster response is needed replace with a copule of @NOP (each taking 500ns @8MHz) or try without any delay at all.
PauseUs 25 ' Or go do something else usefull instead....
Goto Main
Anyway, that's one idea....
/Henrik.
Bookmarks