Your code never reads the joysticks if the button is pressed, so it repeatedly divides the pwm values by two until it decays to zero. That's why the robot stops moving.
Try moving the part that reads the joysticks outside the test for the button.
Code:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
if (p1_sw_trig == 1)
{
pwm13 = (pwm13-127)/2+127;
pwm14 = (pwm14-127)/2+127;
pwm15 = (pwm15-127)/2+127;
pwm16 = (pwm16-127)/2+127;
}
It's safe to do it this way because the pwm values don't actually take effect until the
Generate_PWMs() call at the end of
Process_Data_From_Local_IO().
By the way, if you plan to use timers and serial communication and encoders and other interrupt-based stuff, avoiding pwms 13-16 would be a good idea. They're generated by the user processor and can get somewhat twitchy when interrupts are happening often. Put your motor controls on pwms 1-12 if you want to keep things easy.
(Note that I replaced the
multiply by 0.5 with a
divide by 2. Keeping everything as integers makes sure that the compiler doesn't try to do floating point calculations, which take up a lot more time and program space.)