PIC24FJ256GB106 Oscillator config

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Contact:

PIC24FJ256GB106 Oscillator config

Post 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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1221
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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
Attachments
20.12.jpg
20.12.jpg (235.07 KiB) Viewed 3143 times
Regards
QMESAR

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1221
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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.
Regards
QMESAR

kersing
Valued Contributor
Valued Contributor
Posts: 1961
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1221
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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
Attachments
CLOCK.pdf
Tutorial how to set the clock on 24F
(194.01 KiB) Downloaded 169 times
2.jpg
2.jpg (14.17 KiB) Viewed 3117 times
28.12.jpg
28.12.jpg (77.24 KiB) Viewed 3118 times
Regards
QMESAR

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post by cobra1 »

Thanks guys,
I will get an 8mhz crystal and try again.
Maybe that will simply solve the problem :)

User avatar
Benj
Matrix Staff
Posts: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC24FJ256GB106 Oscillator config

Post 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;

Post Reply