SOLVED... PIC12F1840 Clock Configuration

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

SOLVED... PIC12F1840 Clock Configuration

Post by Brendan »

I'm trying to configure oscillator/clock settings for PIC12F1840 and running into serious issues, looking for help on setting this up as I'm clearly doing something quite wrong.

I wish to use the internal oscillator (8MHz), combined with the x4 PLL, resulting in a 32MHz clock.

I've read elsewhere that the 'OSCCON' register should be configured by supplementary instruction, so I've included a single-line instruction osccon = 0xF3; in a 'C Code' component at the very start of the Flowcode sequence and all compiles without error.

Cutting a long story short, I've experimented with various basic clock settings in the advanced (PPP) chip configuration (without the supplementary C code) resulting in very slow cycling of LEDs on ports in a simple flash sequence, but the above instruction with the configuration settings below result in no apparent function at-all.

Informed guidance gratefully received.


Thanks in advance,
Brendan.
ClockSetupIssues_PIC12F1840_crop.jpg
(217.97 KiB) Downloaded 532 times
Last edited by Brendan on Sun Feb 24, 2013 3:24 pm, edited 3 times in total.

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: Clock configuration issues with PIC12F1840

Post by medelec35 »

Hi Brendan,
With osccon=0xF3
or
With osccon=0xF2

Should force this chip in PLL mode irrespective of the PLL setting
This is because Bit 7 is set to 1
Since Bit 1 is also set to 1 the internal osc should be forced on as well.


Have you tried disabling in circuit debug mode?
Also it's not recommended to have low voltage programming enabled either.
Auto Clear watchdog should not cause the issue, but does not need to be ticked since watchdog timer is disabled.

I am only guessing as I have not got a 12F1840 to test with.
Brendan wrote: so I've included a single-line instruction osccon = 0xF3; in a 'C Code' component at the very start of the Flowcode sequence
That is the correct way of altering internal osc settings

The only way I can think of to test if issues is with pll not active is set osc to 8MHz and see if LED is flashing at the correct rate.

Sorry if not much help.

Martin

Edit: I have not got one of these chips so could not test my theory.
It turns out that 0xF2 & 0xF3 are wrong.

Thanks Brandon for trying those values for me.
I appreciate it.
Last edited by medelec35 on Sun Feb 24, 2013 3:02 pm, edited 2 times in total.
Reason: Corrected some information.
Martin

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Help please: PIC12F1840 Clock Configuration

Post by Brendan »

Thank you Martin for your considered early reply, which gives me confidence that I'm not being entirely stupid :)

In the absence of further suggestions I'll continue in the current vein and post back should I arrive at a successful outcome.



All the best,

Brendan

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: Help please: PIC12F1840 Clock Configuration

Post by medelec35 »

No probs.

Are you using the debugging option?
If so I may know what the issues is had how to get around it.
If not, did it make any difference when debugging in the configuration option was disabled?
Martin

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

Re: Help please: PIC12F1840 Clock Configuration

Post by brandonb »

i use these chips commonly, if running internal, disable all options except brownout detection,
osccon=0x78; //16Mhz
osccon=0xf0;//32Mhz
below is a hex file and fcf with a 1m/s blinky using internal 32Mhz, tested on hardware
Attachments
12f1840 TEMPLATE.hex
(900 Bytes) Downloaded 219 times
12f1840 TEMPLATE.fcf
(6 KiB) Downloaded 260 times

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Help please: PIC12F1840 Clock Configuration

Post by Brendan »

Many thanks Martin, Brandon.
I truly appreciate your time and advice.

I'll not need debug as the code was initially developed and proven on another chip, so will be disabled in-line with recommendations.

Thank you Brandon for the informed settings and sample code. I'll implement your recommendations this morning (sleep is such a bothersome distraction) and confirm in anticipation :D


All the best,

Brendan

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

SOLVED... PIC12F1840 Clock Configuration

Post by Brendan »

UPDATE...

Configuration settings updated to recommendation and all's now working like a charm :D

Thank you again !!!


All the best,

Brendan

Post Reply