What Melanie meant was to examine this piece of code:
Code:
HpwmSet:
HPWM 1,25,1000   '4.00khz
'HPWM 1,25,250   '16.00khz. tried this also.
Return
1 is a constant, 25 is a constant, 1000 is a constant.
If the values in the HPWM statement are all constants, how is a variable in your main loop supposed to change that constant?

If you change
HPWM 1,25,1000
to
HPWM 1,127,1000
all you've done is change the 25 to a 127.

So, WHAT in your code is going to change ANYTHING in your HPWMset subroutine?