PLL mode and PWM frequency settings

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

PLL mode and PWM frequency settings

Post by liak » Mon May 05, 2008 9:23 am

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. :oops:

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Tue Sep 30, 2008 2:55 pm

Have you resolved this issue?

The maximum PWM frequency that can be generated is Fosc/4 - with an 8MHz clock you can get up to 2MHz (5MHz with a 20MHz clock). You do not need ASM - just set set up the registers manually.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Wed Oct 01, 2008 2:27 am

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

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

- added test description.

Post by rmteo » Wed Oct 01, 2008 3:13 am

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.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Wed Oct 01, 2008 2:23 pm

Dear rmteo,
Thanks a lot for the confirmation. :D
That's exactly what I have wanted to know. I don't have a scope to check it. :oops:
Thanks again for settling this doubt for me! :lol:

Regards,
Liak

Post Reply