Re: PWM with a variable frequency timebase?
I hadn't looked at CWG, but looking now I don't think it helps, it appears to be a more versatile version of the earlier "ECCP" steering function so to produce variable width output it still needs a variable width input.
I think where my plan falls down is that the functions I want to use probably all need to be synchronised to the instruction clock (Fosc/4). The rules don't seem to be stated explicitly but MCC complains if I try to configure a different clock source, and it is clearly stated that the "compare" functions do need a synchronised clock.
I have another plan...
I'm wondering if I can use "hardware gate" instead, use FOSC/4 as the clock, but use the NCO1 signal stretched to 4 cycles as the gate for Timer 2. The stretch is to ensure the pulse lasts one instruction cycle so it won't get missed, and since NCO1 isn't in the table of reset sources I probably have to expend another CLC block to route it? The net result should be that the counter only counts when NCO1 pulses, but technically the clock source is still Fosc/4 so the requirement for PWM should still be met?
The output would have more jitter compared to using NCO directly, but then if I fed the PWM through a CLC D-type latch I could synchronise it to the next NCO1 pulse which should leave me with the clean square wave I wanted.
I nearly overlooked the gate function of Timer 2, it seems to be hidden in the description of the external reset source function.