32 mhz internal clock settings

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

32 mhz internal clock settings

Post by brandonb »

i bought a couple 16f1939(i/p) and cant seem to set the internal clock to 32meghz..... all i seem to get is the 16 meg default
Attachments
pic16f1939.fcf
(5.5 KiB) Downloaded 373 times

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 32 mhz internal clock settings

Post by brandonb »

actually i figured it out by using the forum here
Re: Driving Piezo with PIC
by medelec35 » Sun May 22, 2011 4:41 am

nmindana wrote:
the word PLL is new to me, is this used to double the frequency of the main
clock in the PIC?
Nealy.
PLL (Phase Lock Loop) on a few 18F devices and on newer 16F18xx will allow you run the clock speed of the microcontroller at x4 the internal or external oscillator speed.

E.g You can configure the 16F1824 to run with an internal oscillator set at 32MHz
To do this, you configure the internal oscillator to run at 8MHz. Then in the 'Chip', 'Configure..." menu make sure PLL Enable is set to Enable.

Before I can produce a working example:
Can you let me know what target device, type of osc (internal or external) and the frequency of external crystal/ or resonator if either are used.

Martinmedelec35
Valued Contributor


Posts: 1749
Joined: Sat May 05, 2007 6:27 am
Location: Northamptonshire
Has thanked: 119 times
Have thanks: 205 times
Private message
Attachments
pic16f1939 running 32Mhz.fcf
(4 KiB) Downloaded 371 times

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: 32 mhz internal clock settings

Post by Jan Lichtenbelt »

Try osccon= 0xF0; for 32 MHz internal oscillator. (osccon=0x78; is indeed 16 MHz).

Pay attention: At 32 MHz the E_block LCD will fail to show data, due to to short waiting times (which will decraese a factor 20/32).

Kind regrads,

Jan Lichtenbelt

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 32 mhz internal clock settings

Post by medelec35 »

Here are my thoughts.
If you use the calculator that is shipped with windows, then use in programmer mode (windows 7 version)
Select binary mode (you can leave on Qword), and then enter all the numbers I have outlined from 16F1839 data sheet:
osccon reg.png
(66.89 KiB) Downloaded 5256 times
i.e 1110000
Then select Hex mode, you will get the value of 70.
So I would use osccon=0x70;

Jan is correct in saying osccon=0x78; = 16MHz
Martin
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 32 mhz internal clock settings

Post by medelec35 »

Forgot to add:
F0 is also correct. The only difference is the first 1 in 11110000 will be ignored since PLL is enabled within configuration settings.
(at least that’s how I believe it would work anyway):P

Martin
Martin

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 32 mhz internal clock settings

Post by brandonb »

ohh i see where i screwed up, there is 8 bits not 7 thanks i didnt catch that(im a newbie at this) :lol: ..... what i do to conferm actual clock speed is 2 things, if i adjust the speed in the projects options to 32M then command an output on for 1m/s on 1m/s off in loop when check with scope i should have a nice 1m/s pulsewidth 50% dutycycle waveform...... and in the first case i didnt i got 2 m/s on/off that ment i was half the speed i thought i was which was really 16meg..... another way that i so is by commanding an output on and then an output off with out using any king of delay, at 4M it has an on time of 8u/s ... at 8M 4u/s at 16M 2u/s and at 32M 1u/s on time as checked with scope..... the second post does work in hardware by commanding a c block of oscco 70 then enableing 4xpll

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 32 mhz internal clock settings

Post by brandonb »

ohh i see where i screwed up, there is 8 bits not 7 thanks i didnt catch that(im a newbie at this) :lol: ..... what i do to conferm actual clock speed is 2 things, if i adjust the speed in the projects options to 32M then command an output on for 1m/s on 1m/s off in loop when check with scope i should have a nice 1m/s pulsewidth 50% dutycycle waveform...... and in the first case i didnt i got 2 m/s on/off that ment i was half the speed i thought i was which was really 16meg..... another way that i so is by commanding an output on and then an output off with out using any king of delay, at 4M it has an on time of 8u/s ... at 8M 4u/s at 16M 2u/s and at 32M 1u/s on time as checked with scope..... the second post does work in hardware by commanding a c block of oscco 70 (8meg)then enableing 4xpll for the 32M

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 32 mhz internal clock settings

Post by brandonb »

Try osccon= 0xF0; for 32 MHz internal oscillator. (osccon=0x78; is indeed 16 MHz
thanks jan- i had some time to check this out today, hex F0 works great for 32Mhz, out of curiosity i tried it with ppl options off and on and it works both ways, so i turned it off since bit 8 commands ppl on anyway, besides enableing osccon and external pull ups what other items can i use c blocks for to experiment with, im trying to figure out how to understand the datasheets.... i remembered you reply above for the reason why my display doesnt work at 32Mhz, what do you think the highest crystal frequency that the lcd would work for, i was gonna try 26 and 28Mhz

Post Reply