CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PLL pic18f85J90

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bourne



Joined: 07 May 2014
Posts: 10

View user's profile Send private message

PLL pic18f85J90
PostPosted: Wed May 07, 2014 8:15 am     Reply with quote

Hello,
I am trying to make a PLL with a PIC 18f85J90 with a high speed oscillator (quartz at 20MHZ), here is my code:
Code:

#include<18f85J90.h>
#device adc=16
#FUSES HS    //high speed clock
#FUSES NOWDT
#use delay (osc=40000000)  //I want to run the frequency at 40MHZ

 void main (void){
   setup_oscillator(OSC_PLL_ON);

   while(1){

      output_high(PIN_B0);
      delay_ms(200);
      output_low(PIN_B0);
      output_high(PIN_B1);
      
   }
}

I read in the datasheet that the maximum speed frequency for this chip is 40 MHZ (which I wrote in the delay).

My problem is the following, when I decrease the value of the #use delay, my LED are blinking faster than when I let 40000000.
And I also saw that when I use a #use delay crystal at the place of #use delay clock, my LED are blinking faster. I would like to know if my frequency is good increasing (and if the PLL is working or not...)

Finally, I would like to know something. I saw that on many other chips the #fuses allow to activate the pll (with H4 for example) but on this chip, I am able to activate the pll bit but only for the internal clock (at 31 KHZ). Does the line "setup_oscillator (OSC_PLL_ON)" activate the PLL? and if it is not the case, how to activate that bit?
I could see that when I change that line nothing happen.

Finally, do you think my code is correct to make a PLL?
Thanks for your help
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Wed May 07, 2014 8:43 am     Reply with quote

There are a lot of variations of clock/oscillator configurations on PICs. The PIC18f85J90 PLL is quite limited. You can only use the PLL on external high speed crystal, and external oscillator - not with other clock sources, such as internal and low speed.

As on most non-USB PICs, the PLL is four times ONLY. To get the processor to run at 40MHz you have to use a 10MHz crystal or oscillator and enable the PLL by the fuses. You cannot get 40MHz processor clock from a 20MHz crystal. You can run the PIC with a 20MHz crystal, but not with the PLL, and even then not necessarily over the full power voltage and temperature range.
bourne



Joined: 07 May 2014
Posts: 10

View user's profile Send private message

PostPosted: Thu May 08, 2014 1:36 am     Reply with quote

hello RF_Developer

Thank you for your response.

I would like to be sure, the PIC 18F85J90 can run at the 40MHZ maximum?or can I run it to 80MHZ (4x20MHZ) with a PLL?

Thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Thu May 08, 2014 2:08 am     Reply with quote

Read the data sheet. Read the data sheet. Read the data sheet.

Quote (directly from it):

"The HSPLL and ECPLL modes provide the ability to
selectively run the device at 4 times the external oscillating
source to produce frequencies up to 40 MHz." (section 3.4.3).

Up to 40MHz.
4 times the external oscillating source

As RF developer has already told you you can't run the PLL with 20MHz in.
bourne



Joined: 07 May 2014
Posts: 10

View user's profile Send private message

PostPosted: Thu May 08, 2014 7:01 am     Reply with quote

Thank you Ttelmah, you were right the datasheet explained everything.

But there is still something that I cannot explain and I need some help to understand:

When I write this code:
Code:

#FUSES HS   //High speed oscillator
#FUSES H4_SW //PLL ON

#use delay (clock=40000000)

 void main (void){
   setup_oscillator(OSC_PLL_ON);
   while(1){

      output_high(PIN_B0);   //mise à 1 du bit 0 du port B
      delay_ms(200);
      output_low(PIN_B0);
      output_high(PIN_B1);
      delay_ms(200);
      output_low(PIN_B1);
      output_high(PIN_B2);
      delay_ms(200);
      output_low(PIN_B2);
      output_high(PIN_B3);
      delay_ms(200);
      output_low(PIN_B3);
         

   }
}

I can see my LED blinking faster than when i do not write the #fuses H4_SW, I would like to know why, and moreover are they blinking at the crystal's speed?

Thanks for your help
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon May 12, 2014 5:16 pm     Reply with quote

You can't run the PIC that fast.

Look at the MAX OPERATING frequency listed in the datasheet.

If you have a 20MHz crystal on the unit and then enable the PLL, what's 20x4?

(I'll let you do the math)

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group