Page 1 of 1

SOLVED... PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 2:56 am
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

Re: Clock configuration issues with PIC12F1840

Posted: Sun Feb 24, 2013 3:24 am
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.

Re: Help please: PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 3:32 am
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

Re: Help please: PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 4:45 am
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?

Re: Help please: PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 5:53 am
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

Re: Help please: PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 11:55 am
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

SOLVED... PIC12F1840 Clock Configuration

Posted: Sun Feb 24, 2013 2:59 pm
by Brendan
UPDATE...

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

Thank you again !!!


All the best,

Brendan