detecting pwm
Is there a way to detect whether a pwm signal is present on a pin? Currently I can use timers to find the duty of a PWM signal but if there is no signal present the program will hang indefinitely for an event that will never come. Is there a way to do this without implementing a watchdog?

Comments
-Phil
PUB Pulse_detect(Pin) DIRA[pin]~ ctra := 0 ctra[30..26] := %01010 ' set up counter for positive edge detection ctra[5..0] := Pin frqa := 1 waitcnt(10_000+cnt) if phsa > 0 ctra :=0 return 1 else ctra :=0 return 0Problem is it doesn't seem to be working as I would expect it too (of course). See any blatantly obvious mistakes?
PUB Pulse_detect(Pin) DIRA[pin]~ ctra[30..26] := %01010 ' set up counter for positive edge detection ctra[5..0] := Pin frqa := 1 waitcnt(10_000+cnt) ctra := 0 if phsa[COLOR="#FF0000"]~[/COLOR] return 1 [COLOR="silver"]' implied return 0 otherwise[/COLOR]Or reset phsa before waiting. Your choice.Following my own advice here, since frqa stays not equal zero you should clear phsa once the counter is upset:
PUB Pulse_detect(Pin) DIRA[pin]~ ctra[30..26] := %01010 ' set up counter for positive edge detection ctra[5..0] := Pin frqa := 1 phsa := 0 waitcnt(10_000+cnt) ctra := 0 if phsa return 1 [COLOR="silver"]' implied return 0 otherwise[/COLOR]Edit: maybe i jumped the gun a bit for no problems, works one minute and not the next. I'll check latter.
Adds to the BOM...
Here ya go: 20,000 pull-up resistors for $37.05. That's less than two-tenths of a cent apiece.
-Phil