I think Chris H is right.

1. Assume that your transmitter has failed/turned off

2. The receiver never puts out a pulse.

3. If the pulse never happens the variable is set to zero (PBP manual page120)

4. So rcin= - 5360/17 = - 315 and the PBP will turn this into a two's compliment number: 65,221 or $FEC5 or %1111 1110 1100 0101 (if I've got my maths right?) and this is larger than 300 so your code will loop back to 'loop2.'

5. Meanwhile, the PHWM will continue to follow the previous command.

Actually, I suspect that once the transmitter dies and the carrier is lost, the receiver outpus noise and it is this noise, misinterpreted by your software that causes the motor to surge around.

I've not given it much thought but, assuming the problem is not noise and is caused by rcin = 0 because no pulse is ever received then putting

IF rcin < 2 THEN
....kill the HPWM etc...
ENDIF

just after 'the loope2' PULSIN may fix the problem?

Regards Bill legge