I think about the only thing you have to do is:

Code:
    hpwm 0,pwm_value,32767
    pause 300
    CCP1CON = 0
The first line starts the PWM at whatever value is stored in the pwm_variable at 32.767kHz. It then pauses for 300ms then turns off the HPWM.