Hi,
The HPWM command is, according to the manual, limited to 32768Hz as its maximum frequency. Anything higher than that you're going to have to do it "manually", which really isn't very hard.
It's good to run thru the calculations described in the datasheet in order to understand how it all (PWM period vs resolution etc) ties together but there is an excellent tool available called PICMultiCalc which quickly helps you calculate the different values.
I've just run it here and with 4MHz oscillator and 300kHz PWM frequency (333.333kHz) you're only going to get a resolution of 13 "steps".
However, that device has a PLL circuit which can be used with the internal oscillator. If you set the internal oscillator to 8MHz and enable the PLL you'll run the PIC at 32MHz. That will get you 107 "steps" at ~300kHz and 64 "steps" at 500kHz.
/Henrik.




Bookmarks