Dear all,
I am currently using PWM at 100kHz on the CCP1 module of a PIC18F1320 (XTL = 20Mhz) as a serial data clock.
I managed to use the PWM clock after much trouble. But it seems that my routines are not fast enough to allow me to hike up the PWM/clock frequency. The maximum frequency my program will work reliably is around 150kHz, after that, the subroutines will not be able to catch up with the PWM generator, and data will be missed.
I wish I could push the frequency to 400kHz. I am thinking of using PLL for the PIC.
My question is :
After reading through the PWM module provided by David, I don't see how the PLL effect is taken into calculation by the PWM module.
I assume that, if I managed to push the PLL (x4) at XTL = 10Mhz in 18F1320, I would be effectively pushing the PWM frequency to 200kHz in my current program. Is that so? I can't check the output directly since all this while I have been programming without any oscilloscope.
In short, the PWM module provided by David has its SetFreq dependent on the hardware. So if I SetFreq(100000,50) in the program but the output on the new PIC with PLL will effectively generate 200kHz?
I need to know this as my program will operate faster as well with the PLL enabled. I hope I can still push the frequency up to 400Khz. I may have no choice but to go down to asm, but being iliterate in asm is a big problem for me.
PLL mode and PWM frequency settings
Moderators: David Barker, Jerry Messina
Dear rmteo,
I have resolved the issue by other means, changing my entire approach. And it's running well, without the issue becoming an issue anymore.
But just for clarification and confirmation, since I have not tried it on the hardware.
If I enabled PLL on the 18F1320 with XTAL 10Mhz, channeling PWM at 100kHz by using David's pwm module; on the hardware output, will I get a PWM at 400kHz in this settings since I PLLed it?
My main doubt here is the effect of PLL on the pwm frequency set on the registers in the SF module.
Thanks.
Regards,
Liak
I have resolved the issue by other means, changing my entire approach. And it's running well, without the issue becoming an issue anymore.
But just for clarification and confirmation, since I have not tried it on the hardware.
If I enabled PLL on the 18F1320 with XTAL 10Mhz, channeling PWM at 100kHz by using David's pwm module; on the hardware output, will I get a PWM at 400kHz in this settings since I PLLed it?
My main doubt here is the effect of PLL on the pwm frequency set on the registers in the SF module.
Thanks.
Regards,
Liak
- added test description.
I don't know about using David's module as I have not used it. If you set up the PWM by directly manupulating the registers you can get up to a 10MHz PWM with a 10MHz crystal and PLL enabled. This is the absolute fastest speed that can be obtained with just 2 bit duty cycle resolution (4 settings available including 0%). However, at lower speeds, resolution can be up to 10 bits.
===============================================
I just did a quick test. With PLL disabled, I generated PWM (125KHz) and looked at it on a scope. Without any changes except enabling the PLL, the PWM on the scope is 500KHz. I think that the same should apply to David's module as well because by enabling PLL, you are multiplying the hardware clock rate by 4.
===============================================
I just did a quick test. With PLL disabled, I generated PWM (125KHz) and looked at it on a scope. Without any changes except enabling the PLL, the PWM on the scope is 500KHz. I think that the same should apply to David's module as well because by enabling PLL, you are multiplying the hardware clock rate by 4.