So, Consider

if You set HPWM @ 1000 Hz for a default 4Mhz Clock ...

HPWM will run @ 4000 Hz for Xtal @ 16 Mhz

.................. @ 5000 Hz for Xtal @ 20 Mhz


Just correct your HPWM frequencies like that ...

You also can have a look to Genuine examples that show how to use the PWM modules without using the HPWM command ...

Alain