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

Brendan
Posts: 222
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 136 times
Been thanked: 115 times
Contact:

SOLVED... PIC12F1840 Clock Configuration

Postby Brendan » Sun Feb 24, 2013 2:56 am

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8536
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2456 times
Been thanked: 3525 times
Contact:

Re: Clock configuration issues with PIC12F1840

Postby medelec35 » Sun Feb 24, 2013 3:24 am

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.
These users thanked the author medelec35 for the post:
Brendan (Sun Feb 24, 2013 3:37 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Brendan
Posts: 222
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 136 times
Been thanked: 115 times
Contact:

Re: Help please: PIC12F1840 Clock Configuration

Postby Brendan » Sun Feb 24, 2013 3:32 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8536
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2456 times
Been thanked: 3525 times
Contact:

Re: Help please: PIC12F1840 Clock Configuration

Postby medelec35 » Sun Feb 24, 2013 4:45 am

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?
These users thanked the author medelec35 for the post:
Brendan (Sun Feb 24, 2013 11:39 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Postby brandonb » Sun Feb 24, 2013 5:53 am

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
(926 Bytes) Downloaded 74 times
12f1840 TEMPLATE.fcf
(6 KiB) Downloaded 104 times
These users thanked the author brandonb for the post (total 2):
Brendan (Sun Feb 24, 2013 11:40 am) • medelec35 (Sun Feb 24, 2013 12:46 pm)
Rating: 10.53%
 

Brendan
Posts: 222
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 136 times
Been thanked: 115 times
Contact:

Re: Help please: PIC12F1840 Clock Configuration

Postby Brendan » Sun Feb 24, 2013 11:55 am

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: 222
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 136 times
Been thanked: 115 times
Contact:

SOLVED... PIC12F1840 Clock Configuration

Postby Brendan » Sun Feb 24, 2013 2:59 pm

UPDATE...

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

Thank you again !!!


All the best,

Brendan
These users thanked the author Brendan for the post:
Benj (Mon Feb 25, 2013 5:54 pm)
Rating: 5.26%