Look in the manual under 'DEFINE PULSIN_MAX'

I get the feeling that your code is getting 'hung up' waiting for a pulsin, and it doesn't happen, or it's just not arriving when you want it to. Pulsin times out and returns 0 for a value.

If you limit your pulsin to 3ms (DEFINE PULSIN_MAX 300 @ 4Mhz will limit pulsin to 3ms), the program might work like you want it to. But then you have to add some 'error checking' code. I.E., if the pulsin timed out, don't output the 'dead' value, re-output the old value, something along those lines.