I am doing an experiment to build a 400W RF class E amplifier at about 4Mhz.
This means controlling the duty cycle of the pulses governs the amplifier efficiency.
Given the PWM Period:
PWM Period = [(PR2) + 1] • 4 • TOSC•(TMR2 Prescale Value)
It seems that a PR2 of 2 is the max I can get for a 4Mhz PWM drive.
Which just gives 0,25,50,100% PWM settings. Not much control.
The alternative is to make a one shot timer which is driven by a 4Mhz click line and then alter PWM by altering the one shot duration.
But I did up this spice sim to allow for duty cycle mgmt over the range of interest. For the feedback control I'm thinking about averaging the miller current spikes (not sure how yet) thru the FET source and also the current coming thru the class E RFC then creating a ratio from the RFC current pulse of perhaps 80% as a control ref for an opamp to adjust the DC% via biasing the PNP in the sim.
Note the 'loss' current spike where the FET switches while there's still charge in the output capacitance.