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
PIC24FJ256GB106 Oscillator config
Moderator: Benj
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
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 functionalitycobra1 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.
http://www.microchip.com/wwwproducts/De ... e=en531081
Hope it helps
- Attachments
-
- 20.12.jpg (235.07 KiB) Viewed 5626 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 175
- Joined: Thu Feb 04, 2010 7:44 am
- Has thanked: 3 times
- Been thanked: 3 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
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.
Flowcode usually sets up all of this sort of thing itself.
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
It is impossible for FC to do this with the new advance micro controllers there are to many options .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.
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.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
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.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.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
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'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.
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 291 times
-
- 2.jpg (14.17 KiB) Viewed 5600 times
-
- 28.12.jpg (77.24 KiB) Viewed 5601 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 175
- Joined: Thu Feb 04, 2010 7:44 am
- Has thanked: 3 times
- Been thanked: 3 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
Thanks guys,
I will get an 8mhz crystal and try again.
Maybe that will simply solve the problem
I will get an 8mhz crystal and try again.
Maybe that will simply solve the problem
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC24FJ256GB106 Oscillator config
Hello,
Regarding the none available 64MHz oscillator speed option, the datasheet states this.
Regarding the none available 64MHz oscillator speed option, the datasheet states this.
But then in the electrical characteristics section there is this comment which makes me wonder.Up to 16 MIPS Operation at 32 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.For frequencies between 16 MHz and 32 MHz, FMAX = (64 MHz/V) * (VDDCORE – 2V) + 16 MHz.
Code: Select all
CLKDIV = CLKDIV | 0x40;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel