16f1825 Int Osc settings

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

Moderator: Benj

Post Reply
chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

16f1825 Int Osc settings

Post by chipfryer27 »

Hi

Just a quick question.

When trying out a "flash test" (1s on, 1s off) using the above chip on Int Osc, I am getting some serious delay.

With Osc set a 1Mhz the delays are doubled to around 2s
At 4Mhz the delays are around 8s
At 8Mhz the delays are around 16s

I'm guessing I need a block of C-Code at the start as FC might not be able to set the correct registors automatically?

Regards

User avatar
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: 16f1825 Int Osc settings

Post by Benj »

Hello,

The default speed for the INTOSC on the device is 0.5MHz.

For 1MHz operation the line of C code at the start of your program needs to be

Code: Select all

osccon = 0x58;
For 32MHz operation the line of C code at the start of your program needs to be.

Code: Select all

osccon = 0xF0;

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: 16f1825 Int Osc settings

Post by chipfryer27 »

Hi Benj

Thanks for the quick reply.

I am using FC6 and the slowest oscillator setings under Build / General Options is 1Mhz for that chip. I added the C-Code you suggested at the start of my program (but with FC6 still set a 1Mhz) and tried.

The delays now appear to be 100ms or so.

Are the settings in Build / General Options messing things?

Regards

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: 16f1825 Int Osc settings

Post by medelec35 »

First you look at the datasheet for the speed you would like internal oscillator to run at e.g 1MHz:
Datasheet osscon.png
(80.88 KiB) Downloaded 1965 times
Then you can follow this post on how to calculate correct osccon value.

Don't forget to set the clock speed in project options e.g 1000000.

If you still stuck then post flowchart.

Martin
Martin

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: 16f1825 Int Osc settings

Post by chipfryer27 »

Hi Martin

Changed the C-code to 0xd8 and it appears good. I was doing that as you posted. I had read in the datasheet that the default was 500Khz but as FC didn't offer that value it prompted me to ask about the C-code to override the config.

Thanks again you to and Benj
Regards

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: 16f1825 Int Osc settings

Post by kersing »

You can enter your own values for the clock speed by typing the value, the ones offered in the drop down are just often used defaults.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: 16f1825 Int Osc settings

Post by chipfryer27 »

Hi Kersing

Well peel my tangerines.... (to quote Lord Blackadder).

I did not know that.. Doh!

Thanks for that very useful snippet. I thought that as each chip had a drop down, that's what FC imposed. Guess I should really get out less and read more :)

Thanls again,

Regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: 16f1825 Int Osc settings

Post by chipfryer27 »

Hi

Deleted the C-code and by directly entering 500Khz under Build etc it still seems to be running well.

Time now to make it do something more useful.

Thanks again to all

Regards

Post Reply