Page 1 of 1

PIC24FJ256GB106 Oscillator config

Posted: Fri Dec 19, 2014 11:25 pm
by cobra1
I am trying out a new chip, PIC24FJ256GB106.
I have set in the config to primary oscillator HS, and enabled PLL.
I am using a 16mhz external crystal.

I have an LED blinking on and off at 1 second intervals, but to get the correct timing i have to set the frequency in general options to 21Mhz
This is not what i expected.

I have since figured out that i need to write C code at the beginning of the code to correctly set the cock frequency. I am trying to acheive a clock frequency of 32Mhz. Maximum speed for the chip.
Is this possible with a 16mhz crystal or do i have to go down to 8mhz

Can anyone help with the C code to correctly set up the oscillator??

Thanks in advance

Re: PIC24FJ256GB106 Oscillator config

Posted: Sat Dec 20, 2014 11:37 am
by QMESAR
cobra1 wrote:I have an LED blinking on and off at 1 second intervals, but to get the correct timing i have to set the frequency in general options to 21Mhz
This is not what i expected.
It is because you have to set the Clock Divisor .Read the Reference manual for the oscillator which explain how the oscillator function and which registers contains which bits with their functionality

http://www.microchip.com/wwwproducts/De ... e=en531081

Hope it helps

Re: PIC24FJ256GB106 Oscillator config

Posted: Sun Dec 28, 2014 12:53 am
by cobra1
This doesnt really help me much, i dont understand it. Thats why im using flowcode.
Flowcode usually sets up all of this sort of thing itself.

Re: PIC24FJ256GB106 Oscillator config

Posted: Sun Dec 28, 2014 11:40 am
by QMESAR
cobra1 wrote:This doesnt really help me much, i dont understand it. Thats why im using flowcode.
Flowcode usually sets up all of this sort of thing itself.
It is impossible for FC to do this with the new advance micro controllers there are to many options .

I would advise you to use a 8MHZ Crystal with PLL enabled which give you the max allowed clock speed of 32MHZ,I wanted to do the configuration for you with the 16MHZ x PLL which equal 64MHZ and then set the Divisor bits however FC does not allow to enter a higher clock frequency that 32MHZ so I guess the 16MHZ Crystal with FC is not a good choice for an crystal.

Re: PIC24FJ256GB106 Oscillator config

Posted: Sun Dec 28, 2014 12:44 pm
by kersing
QMESAR wrote:however FC does not allow to enter a higher clock frequency that 32MHZ so I guess the 16MHZ Crystal with FC is not a good choice for an crystal.
I'm using frequencies of 120Mhz for certain controllers with Flowcode. Just enter the value manually and all should be fine. Flowcode does not allow entering values above the maximum the chip can run at, so if manually entering the value fails there might be an issue with the chip definition.

Re: PIC24FJ256GB106 Oscillator config

Posted: Sun Dec 28, 2014 1:12 pm
by QMESAR
'm using frequencies of 120Mhz for certain controllers with Flowcode. Just enter the value manually and all should be fine. Flowcode does not allow entering values above the maximum the chip can run at, so if manually entering the value fails there might be an issue with the chip definition.
yes I agree I am using 140Mhz on a dsPIC33EP but for a PIC24F FC allow me only to enter 32MHZ the reason I suggested to use the 8MHZ Crystal that would allow the max 32MHZ(16MIPS) for an 24F and and the the users timing issue will be solved n FC is happy and the user is happy too :D

Then from the reference manual for 24F the max is 32MHZ again 16MHZ Clock and PLL makes no sense to use for PIC24F

To cobra1 attached a tutorial how to configure PIC24F clock speeds and settings

Hope it helps you

Re: PIC24FJ256GB106 Oscillator config

Posted: Wed Dec 31, 2014 5:57 pm
by cobra1
Thanks guys,
I will get an 8mhz crystal and try again.
Maybe that will simply solve the problem :)

Re: PIC24FJ256GB106 Oscillator config

Posted: Mon Jan 05, 2015 5:04 pm
by Benj
Hello,

Regarding the none available 64MHz oscillator speed option, the datasheet states this.
Up to 16 MIPS Operation at 32 MHz
But then in the electrical characteristics section there is this comment which makes me wonder.
For frequencies between 16 MHz and 32 MHz, FMAX = (64 MHz/V) * (VDDCORE – 2V) + 16 MHz.
A 16MHz crystal should be ok just add this to the start of your program in a C icon and set the project clock speed to 32000000.

Code: Select all

CLKDIV = CLKDIV | 0x40;