I'm thinking about making a linear, "set-and-forget" PWM signal on the PIC16F1773 that is able to run during sleep and does not require intervention to update the duty cycle. I'm currently weighing two options.
The first uses two PWM modules whose period is set by a small beat frequency, fed to the Complementary Waveform Generator (COG) in "steered PWM mode". In this mode, I can fairly easily define rising and falling edge output events based on the source PWMs, to have a constant period and variable duty cycle.
The second requires one fewer module - only two PWMs are needed, where one is a parent, one is a child, and the parent's offset events reset the PWM counter of the child. The literature calls this "Continuous run [child] mode with sync start and timer reset". Unfortunately, if my interpretation is correct, this mode would not allow for an unsupervised variable duty cycle without also varying the period - effectively the high-time would be constant and the low-time would see linear reduction to zero.
Given that this is driving a LED at ~150Hz, nanosecond-level timing accuracy isn't all that crucial. This system is also not sensitive to very many power considerations, since it's fed by a beefy SMPS with no battery in the picture.
The only major trade-offs I see are:
- The COG solution draws the additional power of one more module, but given that the frequency of the PWM-only solution ramps up, the increased frequency of CMOS transitions makes power comparison non-trivial
- If I had a sensitive analogue section (which I don't), the variable-frequency approach could make spectral pollution more difficult to control
- The variable-frequency approach does not support starting at zero duty cycle, because there must be some constant, non-zero high time
I think the last point is the only one applicable to my situation, which pushes me toward the COG solution. Have I missed any other considerations?