totally missing the point
CCPR1L = $14 not 14 ; its hex 14 or dec 20
totally missing the point
CCPR1L = $14 not 14 ; its hex 14 or dec 20
Warning I'm not a teacher
It is a 10bit PWM system but the resolution of the PWM signal depends on the PWM period or frequency. Higher the frequency, the lower the resolution.
So, at 20MHz and a frequency signal of 125KHz, the resolution will be 7 bits only, even though the control register is 10bit wide.
Ioannis
Ioannis,
Thanks for the feedback!
I have been using the attached calculator from Mister E.
Is the Duty Step % (0.625) X 50% = 31.25% the problem?
(I am measuring 3.8uS On / 4.2uS Off)
How can I set it for 4mS On / 4mS exactly?
(FYI, I am headed towards filtering the Square wave into a Sine wave and want it to be symetrical.)
Is this even doable with the ancient 16F628?
I am only using this because I had the Dev Boards handy.
Do you remember Bruce Reynolds?
What would you recommend for a 8PIN Dip?
Peace,
Jay Zebryk
Referencing the Mister e Calculator, it looks like the best resolution you can get is 0 to 160, where 160 will be 100% Duty Cycle.
Hi,
That implies one needs to set the Duty Cycle to 80 to get a 4uS On / 4uS Off square wave?
(This does not make sense to me.)
Thanks,
Jay Zebryk
Richard already covered it but it seems to have been overlooked.
The duty cycle register is 10bit wide but, as Ioannis says, the usable number of bits differs depending on the PWM period. The calculator tells you that for 125kHz (with PR2=39) varying the duty cycle register from 0 to 160 will give you a duty cycle of 0-100%.
For 50% duty cycle you obviously want to set the register to 80.
Now, remember that the register is 10bit wide and that two low order bits are in CCP1CON so what goes in CCPR1L is the top 8 bits of the 10bit value. Or, in this case 80/4=20 which, as Richard rightly points out is $14.
your understanding is flawed and math is incorrectIs the Duty Step % (0.625) X 50% = 31.25% the problem?(I am measuring 3.8uS On / 4.2uS Off)
How can I set it for 4mS On / 4mS exactly?
Duty is Steps x 0.625% // steps = CCPR1L x4 + CCP1CON<5:4>
so:
80x0.625% = 50% <=> steps = 20x4 + 0
56x0.625% = 35% <=> steps = 14x4 + 0
Warning I'm not a teacher
Bookmarks