Cannot configure Internal Oscillator

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

Moderator: Benj

Post Reply
Clive44
Posts: 52
Joined: Tue Oct 18, 2011 12:35 pm
Has thanked: 3 times
Contact:

Cannot configure Internal Oscillator

Post by Clive44 »

Hi

I've had trouble getting a graphics LCD ILI9341 to work on SPI.
I'm using a PIC18F45K22 with the internal RC Oscillator.
When I run the '1 second test' it is 8 x slow. i.e. 8 seconds up, 8 seconds down instead of 1 second up, 1 second down.
I have attached some screen shots.
What am I doing wrong?

Thanks

Clive
Attachments
Screenshot IntOsc Helper.jpg
Screenshot IntOsc Helper.jpg (46.79 KiB) Viewed 3514 times
Screenshot General Options.jpg
Screenshot General Options.jpg (28.25 KiB) Viewed 3514 times
Screenshot Configure.jpg
Screenshot Configure.jpg (81.45 KiB) Viewed 3514 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Cannot configure Internal Oscillator

Post by QMESAR »

Hi
I never used this chip however I haven't seen a PIC18 that can run at 80Mhz the max I expects 64Mhz
I would guess that in the OSC Helper you select the Internal OSC speed as 16Mhz (click on the OSC parameter and a list box will open that shows the various speeds the Internal OSC can run at.
Then select 16MHz with your 4 times PLL enabled that = 64 Mhz also set the Clock frequency in the Flowcode Properties as 64MHz and try again do not forget to write the new OSC helper value for the OSCCON to the OSCCON regsiter with a C Icon


p1.jpg
p1.jpg (25.44 KiB) Viewed 3502 times
P2.jpg
P2.jpg (13.42 KiB) Viewed 3502 times

edit :Sorry just saw now chipfryer is correct I saw 1 zero to many :D
However 8Mhz with PLL enabled is not 8Mhz Clock ,that would be 32Mhz assuming the the PLL has an effect with Internal OSC something to check from the data sheet

chipfryer27
Valued Contributor
Valued Contributor
Posts: 736
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 185 times
Been thanked: 204 times
Contact:

Re: Cannot configure Internal Oscillator

Post by chipfryer27 »

Hi

Looks like you have a "typo" in your C-Code block. You accidentally put your Osconn setting within the comment parameters.

In your C-Code block, just have :-

OSCONN=0x60;

Regards

Clive44
Posts: 52
Joined: Tue Oct 18, 2011 12:35 pm
Has thanked: 3 times
Contact:

Re: Cannot configure Internal Oscillator

Post by Clive44 »

Hi chipfryer27 and QMESAR

Thanks for your help and advice.
I've spent some time 'playing' this afternoon and these are the results -

In all Tests below, The Oscillator Selection Bits (In the Configure tab) is set to "Internal Oscillator block, CLKOUT function on RA6, port function on RA7

TEST NO.1
In General Options - Clock Speed set to 64,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON not used in the flowchart
RESULTS - FAIL
1 sec on RA0 actually measures 64 seconds!
CLKOUT on RA6 = 250KHz
ie Internal oscillator running at 1MHz not 64MHz

TEST NO.2
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON not used in the flowchart
RESULTS - FAIL
1 sec on RA0 actually measures 16 seconds
CLKOUT on RA6 = still 250KHz
ie Internal oscillator running at 1MHz not 64MHz

TEST NO.3
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Enabled
OSCCON set to 0x70 (16MHz) in flowchart
RESULTS - PASS
1 sec on RA0 actually measures 1 second!
CLKOUT on RA6 = 4MHz
ie Internal oscillator running at 16MHz

TEST NO.4
In General Options - Clock Speed set to 16,000,000
In Configure - 4 x PLL Enable - Disabled
OSCCON set to 0x70 (16MHz) in flowchart
RESULTS - PASS
1 sec on RA0 actually measures 1 second!
CLKOUT on RA6 = 4MHz
ie Internal oscillator running at 16MHz

So the 4 x PLL option doesn't do anything?
Also the only way to get the internal oscillator to run at 16MHz is via the OSCCON command. Whatever you set in General options seems to be ignored?
I've ordered in some PIC18F47K40 chips to try to see if they perform the same.

Regards

Clive

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: Cannot configure Internal Oscillator

Post by medelec35 »

Hi Clive,
For 64 MHz
Can you try setting internal clock speed to 64000000.
Then add C code block with

Code: Select all

OSCCON = 0x70;
st_bit(OSCTUNE,PLLEN);
Also If display is not working,
Try setting SPI to software mode.
If that fails then try at 32MHz
Martin

Clive44
Posts: 52
Joined: Tue Oct 18, 2011 12:35 pm
Has thanked: 3 times
Contact:

Re: Cannot configure Internal Oscillator

Post by Clive44 »

Thanks Martin

I'll try what you suggested and let you know the results!

Cheers

Clive

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: Cannot configure Internal Oscillator

Post by medelec35 »

Your'e welcome Clive.
It's my understanding that PLL in options is for crystal only and

Code: Select all

st_bit(OSCTUNE,PLLEN);
is for internal OSC only?
Martin

Clive44
Posts: 52
Joined: Tue Oct 18, 2011 12:35 pm
Has thanked: 3 times
Contact:

Re: Cannot configure Internal Oscillator

Post by Clive44 »

Hi Martin

Sory I've taken so long to get back to you!

That works - thanks for your help. Much appreciated.

Clive

Post Reply