Pulsin should work, but you need to specify if your pulse is a high or a low... let's it's assume it's a positive-going 'High'. Pulsin measures in 10uS increments (at 4MHz PIC clock), and we'll set our threshold at 450mS (that's a count of 45,000 ticks at 10us)
PulsePin var PortB.2
PulseData var WORD
PulseLoop:
Pulsin PulsePin,1,PulseData
If PulseData<45000 then goto Pulseloop
If your code is trapped in the loop then you have either a Pulse that's too short, or greater than 655.35mS (WORD limit for Pulsin). So you can see that Pulsin will give you a 'window' to work within. It won't catch very long pulses that exceed it's max limit.
Now let's rehash this giving us an unlimited upper Pulse width window...
PulseLoop:
PulseData=0 ' zero count
While PulsePin=0:Wend ' wait here for a pulse to start
While PulsePin=1 ' Loop here counting Pulse Length in 1mS steps
Pause 1
PulseData=PulseData+1
If PulseData>450 then goto GotLongPulse
Wend
Goto PulseLoop
Now, in this example, if your Pulse LOW is less than 1mS you may not catch the start of the next pulse if it follows on too fast, so just change Pause1 to PauseUS 100 and increase >450 to >4500 and you now have a 100uS count window. And pro rata etc etc...
Melanie
Bookmarks