I dunno!!!
I could very well be wrong (in this particular, singular, one time case I don't think I am), but it looks to me (at least in the 18F4620 and 18F4685 datasheet) that Timer2 (which is the base timer for the CCP and ECCP) is driven off of the Fosc/4 (i.e. instruction cycle), therefore, 500khz is max.
See figure 15-3, Note 1, on page 144, of the PIC18F4620 datasheet (DS39626D)
-Note 1: The 8-bit TMR2 value is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler, to create the 10-bit time base.
Also, see Equation 15-1 on the right side of that same page:
-When TMR2 is equal to PR2, the following three events occur on the next increment cycle:
• TMR2 is cleared
• The CCPx pin is set (exception: if PWM duty cycle = 0%, the CCPx pin will not be set)
• The PWM duty cycle is latched from CCPRxL into CCPRxH
Changing the CCP1 registers will only change frequency, not duty cycle, which won't change anyways because PR2 is 0.
I wish I was near my hardware so I could beat this up...try it out and break something!
But I was just thinking...if it actually did run 2Mhz, this might be a neat way to 'stack PWMs' (if that's even a word or a method of doing anything at all, maybe battery charging?).
You could have a hardware PWM buzzing along at 2Mhz at a few duty cycles, run that output into an AND gate, with the other input to the AND being run by a 'not so fast' software PWM, or even another PWM channel. Something like a boost-converter might benefit from a stacked PWM like that. Gotta have high freq to get good conversion efficiency...
Bookmarks