View previous topic :: View next topic |
Author |
Message |
Mrinmoy Dey
Joined: 23 Jan 2018 Posts: 44
|
PIC24FJ256GA705 Clock & PLL confusion |
Posted: Mon Sep 13, 2021 5:53 am |
|
|
Hi,
I am using PIC24FJ256GA705 in one of my project and my compiler version is 5.083. My crystal oscillator is 8Mhz and I want to use PLL with 4 times. What should be the correct fuses bit to use PLL4 or PLL4X?
Again, in
#use delay(clock=?)
what should I write in clock speed for above mention scenario 8MHz or 32MHz?
Thanks in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Mon Sep 13, 2021 7:43 am |
|
|
Just specify the crystal, and the final clock rate.
So:
#use delay(crystal=8MHz, clock=32MHz)
tells the compiler to set this up.
There are actually two different ways this can be programmed. The first
would need /2, followed by the *24 PLL, and then the default /3 divisor.
In fact it should use the alternative PLL 'route' for this, which simply
offers *4, *6 or *8.
Just setting the clock like this, provided you don't specify any clock fuses,
will automatically set these. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Sep 13, 2021 8:48 am |
|
|
A further comment...
Structure your program to set the fuses first, then specify the clock settings. If you reverse the order, you can inadvertently overwrite the proper clock fuses. |
|
|
Mrinmoy Dey
Joined: 23 Jan 2018 Posts: 44
|
|
Posted: Mon Sep 13, 2021 11:14 pm |
|
|
@Ttelmah
Thank you sir.
So, all over what I understand is by setting crystal and clock in "#use delay" will automatically set the PLL; no need to set PLL fuse bits explicitly. |
|
|
Mrinmoy Dey
Joined: 23 Jan 2018 Posts: 44
|
|
Posted: Mon Sep 13, 2021 11:15 pm |
|
|
@newguy
Yes, I set my all program exactly the same way you suggested. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Tue Sep 14, 2021 6:03 am |
|
|
Yes,
On most of the other DsPIC's, it has to be done this way, because their PLL's
are setup in software after boot. Yours is one of the few where the PLL can
be set in fuses.
However the key with #use delay, is that there are quite a few 'extras',
beyond the basic clock rate setting abilities, So (for instance) you can also
program the USB clocks on some chips, and specify separately the actual
oscillator and final clock, which then makes it do the PLL settings (if it
can). If you specify a clock it can't actually achieve, it will give a warning. |
|
|
|